
kernel/kernel:     file format elf64-littleriscv


Disassembly of section .text:

0000000080000000 <_entry>:
    80000000:	00009117          	auipc	sp,0x9
    80000004:	81013103          	ld	sp,-2032(sp) # 80008810 <_GLOBAL_OFFSET_TABLE_+0x8>
    80000008:	6505                	lui	a0,0x1
    8000000a:	f14025f3          	csrr	a1,mhartid
    8000000e:	0585                	addi	a1,a1,1
    80000010:	02b50533          	mul	a0,a0,a1
    80000014:	912a                	add	sp,sp,a0
    80000016:	076000ef          	jal	ra,8000008c <start>

000000008000001a <spin>:
    8000001a:	a001                	j	8000001a <spin>

000000008000001c <timerinit>:
// which arrive at timervec in kernelvec.S,
// which turns them into software interrupts for
// devintr() in trap.c.
void
timerinit()
{
    8000001c:	1141                	addi	sp,sp,-16
    8000001e:	e422                	sd	s0,8(sp)
    80000020:	0800                	addi	s0,sp,16
// which hart (core) is this?
static inline uint64
r_mhartid()
{
  uint64 x;
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    80000022:	f14027f3          	csrr	a5,mhartid
  // each CPU has a separate source of timer interrupts.
  int id = r_mhartid();
    80000026:	0007859b          	sext.w	a1,a5

  // ask the CLINT for a timer interrupt.
  int interval = 1000000; // cycles; about 1/10th second in qemu.
  *(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
    8000002a:	0037979b          	slliw	a5,a5,0x3
    8000002e:	02004737          	lui	a4,0x2004
    80000032:	97ba                	add	a5,a5,a4
    80000034:	0200c737          	lui	a4,0x200c
    80000038:	ff873703          	ld	a4,-8(a4) # 200bff8 <_entry-0x7dff4008>
    8000003c:	000f4637          	lui	a2,0xf4
    80000040:	24060613          	addi	a2,a2,576 # f4240 <_entry-0x7ff0bdc0>
    80000044:	9732                	add	a4,a4,a2
    80000046:	e398                	sd	a4,0(a5)

  // prepare information in scratch[] for timervec.
  // scratch[0..2] : space for timervec to save registers.
  // scratch[3] : address of CLINT MTIMECMP register.
  // scratch[4] : desired interval (in cycles) between timer interrupts.
  uint64 *scratch = &timer_scratch[id][0];
    80000048:	00259693          	slli	a3,a1,0x2
    8000004c:	96ae                	add	a3,a3,a1
    8000004e:	068e                	slli	a3,a3,0x3
    80000050:	00009717          	auipc	a4,0x9
    80000054:	ff070713          	addi	a4,a4,-16 # 80009040 <timer_scratch>
    80000058:	9736                	add	a4,a4,a3
  scratch[3] = CLINT_MTIMECMP(id);
    8000005a:	ef1c                	sd	a5,24(a4)
  scratch[4] = interval;
    8000005c:	f310                	sd	a2,32(a4)
}

static inline void 
w_mscratch(uint64 x)
{
  asm volatile("csrw mscratch, %0" : : "r" (x));
    8000005e:	34071073          	csrw	mscratch,a4
  asm volatile("csrw mtvec, %0" : : "r" (x));
    80000062:	00006797          	auipc	a5,0x6
    80000066:	57e78793          	addi	a5,a5,1406 # 800065e0 <timervec>
    8000006a:	30579073          	csrw	mtvec,a5
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    8000006e:	300027f3          	csrr	a5,mstatus

  // set the machine-mode trap handler.
  w_mtvec((uint64)timervec);

  // enable machine-mode interrupts.
  w_mstatus(r_mstatus() | MSTATUS_MIE);
    80000072:	0087e793          	ori	a5,a5,8
  asm volatile("csrw mstatus, %0" : : "r" (x));
    80000076:	30079073          	csrw	mstatus,a5
  asm volatile("csrr %0, mie" : "=r" (x) );
    8000007a:	304027f3          	csrr	a5,mie

  // enable machine-mode timer interrupts.
  w_mie(r_mie() | MIE_MTIE);
    8000007e:	0807e793          	ori	a5,a5,128
  asm volatile("csrw mie, %0" : : "r" (x));
    80000082:	30479073          	csrw	mie,a5
}
    80000086:	6422                	ld	s0,8(sp)
    80000088:	0141                	addi	sp,sp,16
    8000008a:	8082                	ret

000000008000008c <start>:
{
    8000008c:	1141                	addi	sp,sp,-16
    8000008e:	e406                	sd	ra,8(sp)
    80000090:	e022                	sd	s0,0(sp)
    80000092:	0800                	addi	s0,sp,16
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    80000094:	300027f3          	csrr	a5,mstatus
  x &= ~MSTATUS_MPP_MASK;
    80000098:	7779                	lui	a4,0xffffe
    8000009a:	7ff70713          	addi	a4,a4,2047 # ffffffffffffe7ff <end+0xffffffff7ffdd7ff>
    8000009e:	8ff9                	and	a5,a5,a4
  x |= MSTATUS_MPP_S;
    800000a0:	6705                	lui	a4,0x1
    800000a2:	80070713          	addi	a4,a4,-2048 # 800 <_entry-0x7ffff800>
    800000a6:	8fd9                	or	a5,a5,a4
  asm volatile("csrw mstatus, %0" : : "r" (x));
    800000a8:	30079073          	csrw	mstatus,a5
  asm volatile("csrw mepc, %0" : : "r" (x));
    800000ac:	00001797          	auipc	a5,0x1
    800000b0:	dc078793          	addi	a5,a5,-576 # 80000e6c <main>
    800000b4:	34179073          	csrw	mepc,a5
  asm volatile("csrw satp, %0" : : "r" (x));
    800000b8:	4781                	li	a5,0
    800000ba:	18079073          	csrw	satp,a5
  asm volatile("csrw medeleg, %0" : : "r" (x));
    800000be:	67c1                	lui	a5,0x10
    800000c0:	17fd                	addi	a5,a5,-1 # ffff <_entry-0x7fff0001>
    800000c2:	30279073          	csrw	medeleg,a5
  asm volatile("csrw mideleg, %0" : : "r" (x));
    800000c6:	30379073          	csrw	mideleg,a5
  asm volatile("csrr %0, sie" : "=r" (x) );
    800000ca:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    800000ce:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    800000d2:	10479073          	csrw	sie,a5
  timerinit();
    800000d6:	00000097          	auipc	ra,0x0
    800000da:	f46080e7          	jalr	-186(ra) # 8000001c <timerinit>
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    800000de:	f14027f3          	csrr	a5,mhartid
  w_tp(id);
    800000e2:	2781                	sext.w	a5,a5
}

static inline void 
w_tp(uint64 x)
{
  asm volatile("mv tp, %0" : : "r" (x));
    800000e4:	823e                	mv	tp,a5
  asm volatile("mret");
    800000e6:	30200073          	mret
}
    800000ea:	60a2                	ld	ra,8(sp)
    800000ec:	6402                	ld	s0,0(sp)
    800000ee:	0141                	addi	sp,sp,16
    800000f0:	8082                	ret

00000000800000f2 <consolewrite>:
//
// user write()s to the console go here.
//
int
consolewrite(int user_src, uint64 src, int n)
{
    800000f2:	715d                	addi	sp,sp,-80
    800000f4:	e486                	sd	ra,72(sp)
    800000f6:	e0a2                	sd	s0,64(sp)
    800000f8:	fc26                	sd	s1,56(sp)
    800000fa:	f84a                	sd	s2,48(sp)
    800000fc:	f44e                	sd	s3,40(sp)
    800000fe:	f052                	sd	s4,32(sp)
    80000100:	ec56                	sd	s5,24(sp)
    80000102:	0880                	addi	s0,sp,80
  int i;

  for(i = 0; i < n; i++){
    80000104:	04c05763          	blez	a2,80000152 <consolewrite+0x60>
    80000108:	8a2a                	mv	s4,a0
    8000010a:	84ae                	mv	s1,a1
    8000010c:	89b2                	mv	s3,a2
    8000010e:	4901                	li	s2,0
    char c;
    if(either_copyin(&c, user_src, src+i, 1) == -1)
    80000110:	5afd                	li	s5,-1
    80000112:	4685                	li	a3,1
    80000114:	8626                	mv	a2,s1
    80000116:	85d2                	mv	a1,s4
    80000118:	fbf40513          	addi	a0,s0,-65
    8000011c:	00002097          	auipc	ra,0x2
    80000120:	356080e7          	jalr	854(ra) # 80002472 <either_copyin>
    80000124:	01550d63          	beq	a0,s5,8000013e <consolewrite+0x4c>
      break;
    uartputc(c);
    80000128:	fbf44503          	lbu	a0,-65(s0)
    8000012c:	00000097          	auipc	ra,0x0
    80000130:	77e080e7          	jalr	1918(ra) # 800008aa <uartputc>
  for(i = 0; i < n; i++){
    80000134:	2905                	addiw	s2,s2,1
    80000136:	0485                	addi	s1,s1,1
    80000138:	fd299de3          	bne	s3,s2,80000112 <consolewrite+0x20>
    8000013c:	894e                	mv	s2,s3
  }

  return i;
}
    8000013e:	854a                	mv	a0,s2
    80000140:	60a6                	ld	ra,72(sp)
    80000142:	6406                	ld	s0,64(sp)
    80000144:	74e2                	ld	s1,56(sp)
    80000146:	7942                	ld	s2,48(sp)
    80000148:	79a2                	ld	s3,40(sp)
    8000014a:	7a02                	ld	s4,32(sp)
    8000014c:	6ae2                	ld	s5,24(sp)
    8000014e:	6161                	addi	sp,sp,80
    80000150:	8082                	ret
  for(i = 0; i < n; i++){
    80000152:	4901                	li	s2,0
    80000154:	b7ed                	j	8000013e <consolewrite+0x4c>

0000000080000156 <consoleread>:
// user_dist indicates whether dst is a user
// or kernel address.
//
int
consoleread(int user_dst, uint64 dst, int n)
{
    80000156:	7159                	addi	sp,sp,-112
    80000158:	f486                	sd	ra,104(sp)
    8000015a:	f0a2                	sd	s0,96(sp)
    8000015c:	eca6                	sd	s1,88(sp)
    8000015e:	e8ca                	sd	s2,80(sp)
    80000160:	e4ce                	sd	s3,72(sp)
    80000162:	e0d2                	sd	s4,64(sp)
    80000164:	fc56                	sd	s5,56(sp)
    80000166:	f85a                	sd	s6,48(sp)
    80000168:	f45e                	sd	s7,40(sp)
    8000016a:	f062                	sd	s8,32(sp)
    8000016c:	ec66                	sd	s9,24(sp)
    8000016e:	e86a                	sd	s10,16(sp)
    80000170:	1880                	addi	s0,sp,112
    80000172:	8aaa                	mv	s5,a0
    80000174:	8a2e                	mv	s4,a1
    80000176:	89b2                	mv	s3,a2
  uint target;
  int c;
  char cbuf;

  target = n;
    80000178:	00060b1b          	sext.w	s6,a2
  acquire(&cons.lock);
    8000017c:	00011517          	auipc	a0,0x11
    80000180:	00450513          	addi	a0,a0,4 # 80011180 <cons>
    80000184:	00001097          	auipc	ra,0x1
    80000188:	a3e080e7          	jalr	-1474(ra) # 80000bc2 <acquire>
  while(n > 0){
    // wait until interrupt handler has put some
    // input into cons.buffer.
    while(cons.r == cons.w){
    8000018c:	00011497          	auipc	s1,0x11
    80000190:	ff448493          	addi	s1,s1,-12 # 80011180 <cons>
      if(myproc()->killed){
        release(&cons.lock);
        return -1;
      }
      sleep(&cons.r, &cons.lock);
    80000194:	00011917          	auipc	s2,0x11
    80000198:	08490913          	addi	s2,s2,132 # 80011218 <cons+0x98>
    }

    c = cons.buf[cons.r++ % INPUT_BUF];

    if(c == C('D')){  // end-of-file
    8000019c:	4b91                	li	s7,4
      break;
    }

    // copy the input byte to the user-space buffer.
    cbuf = c;
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    8000019e:	5c7d                	li	s8,-1
      break;

    dst++;
    --n;

    if(c == '\n'){
    800001a0:	4ca9                	li	s9,10
  while(n > 0){
    800001a2:	07305863          	blez	s3,80000212 <consoleread+0xbc>
    while(cons.r == cons.w){
    800001a6:	0984a783          	lw	a5,152(s1)
    800001aa:	09c4a703          	lw	a4,156(s1)
    800001ae:	02f71463          	bne	a4,a5,800001d6 <consoleread+0x80>
      if(myproc()->killed){
    800001b2:	00001097          	auipc	ra,0x1
    800001b6:	7f8080e7          	jalr	2040(ra) # 800019aa <myproc>
    800001ba:	591c                	lw	a5,48(a0)
    800001bc:	e7b5                	bnez	a5,80000228 <consoleread+0xd2>
      sleep(&cons.r, &cons.lock);
    800001be:	85a6                	mv	a1,s1
    800001c0:	854a                	mv	a0,s2
    800001c2:	00002097          	auipc	ra,0x2
    800001c6:	000080e7          	jalr	ra # 800021c2 <sleep>
    while(cons.r == cons.w){
    800001ca:	0984a783          	lw	a5,152(s1)
    800001ce:	09c4a703          	lw	a4,156(s1)
    800001d2:	fef700e3          	beq	a4,a5,800001b2 <consoleread+0x5c>
    c = cons.buf[cons.r++ % INPUT_BUF];
    800001d6:	0017871b          	addiw	a4,a5,1
    800001da:	08e4ac23          	sw	a4,152(s1)
    800001de:	07f7f713          	andi	a4,a5,127
    800001e2:	9726                	add	a4,a4,s1
    800001e4:	01874703          	lbu	a4,24(a4)
    800001e8:	00070d1b          	sext.w	s10,a4
    if(c == C('D')){  // end-of-file
    800001ec:	077d0563          	beq	s10,s7,80000256 <consoleread+0x100>
    cbuf = c;
    800001f0:	f8e40fa3          	sb	a4,-97(s0)
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    800001f4:	4685                	li	a3,1
    800001f6:	f9f40613          	addi	a2,s0,-97
    800001fa:	85d2                	mv	a1,s4
    800001fc:	8556                	mv	a0,s5
    800001fe:	00002097          	auipc	ra,0x2
    80000202:	21e080e7          	jalr	542(ra) # 8000241c <either_copyout>
    80000206:	01850663          	beq	a0,s8,80000212 <consoleread+0xbc>
    dst++;
    8000020a:	0a05                	addi	s4,s4,1
    --n;
    8000020c:	39fd                	addiw	s3,s3,-1
    if(c == '\n'){
    8000020e:	f99d1ae3          	bne	s10,s9,800001a2 <consoleread+0x4c>
      // a whole line has arrived, return to
      // the user-level read().
      break;
    }
  }
  release(&cons.lock);
    80000212:	00011517          	auipc	a0,0x11
    80000216:	f6e50513          	addi	a0,a0,-146 # 80011180 <cons>
    8000021a:	00001097          	auipc	ra,0x1
    8000021e:	a5c080e7          	jalr	-1444(ra) # 80000c76 <release>

  return target - n;
    80000222:	413b053b          	subw	a0,s6,s3
    80000226:	a811                	j	8000023a <consoleread+0xe4>
        release(&cons.lock);
    80000228:	00011517          	auipc	a0,0x11
    8000022c:	f5850513          	addi	a0,a0,-168 # 80011180 <cons>
    80000230:	00001097          	auipc	ra,0x1
    80000234:	a46080e7          	jalr	-1466(ra) # 80000c76 <release>
        return -1;
    80000238:	557d                	li	a0,-1
}
    8000023a:	70a6                	ld	ra,104(sp)
    8000023c:	7406                	ld	s0,96(sp)
    8000023e:	64e6                	ld	s1,88(sp)
    80000240:	6946                	ld	s2,80(sp)
    80000242:	69a6                	ld	s3,72(sp)
    80000244:	6a06                	ld	s4,64(sp)
    80000246:	7ae2                	ld	s5,56(sp)
    80000248:	7b42                	ld	s6,48(sp)
    8000024a:	7ba2                	ld	s7,40(sp)
    8000024c:	7c02                	ld	s8,32(sp)
    8000024e:	6ce2                	ld	s9,24(sp)
    80000250:	6d42                	ld	s10,16(sp)
    80000252:	6165                	addi	sp,sp,112
    80000254:	8082                	ret
      if(n < target){
    80000256:	0009871b          	sext.w	a4,s3
    8000025a:	fb677ce3          	bgeu	a4,s6,80000212 <consoleread+0xbc>
        cons.r--;
    8000025e:	00011717          	auipc	a4,0x11
    80000262:	faf72d23          	sw	a5,-70(a4) # 80011218 <cons+0x98>
    80000266:	b775                	j	80000212 <consoleread+0xbc>

0000000080000268 <consputc>:
{
    80000268:	1141                	addi	sp,sp,-16
    8000026a:	e406                	sd	ra,8(sp)
    8000026c:	e022                	sd	s0,0(sp)
    8000026e:	0800                	addi	s0,sp,16
  if(c == BACKSPACE){
    80000270:	10000793          	li	a5,256
    80000274:	00f50a63          	beq	a0,a5,80000288 <consputc+0x20>
    uartputc_sync(c);
    80000278:	00000097          	auipc	ra,0x0
    8000027c:	560080e7          	jalr	1376(ra) # 800007d8 <uartputc_sync>
}
    80000280:	60a2                	ld	ra,8(sp)
    80000282:	6402                	ld	s0,0(sp)
    80000284:	0141                	addi	sp,sp,16
    80000286:	8082                	ret
    uartputc_sync('\b'); uartputc_sync(' '); uartputc_sync('\b');
    80000288:	4521                	li	a0,8
    8000028a:	00000097          	auipc	ra,0x0
    8000028e:	54e080e7          	jalr	1358(ra) # 800007d8 <uartputc_sync>
    80000292:	02000513          	li	a0,32
    80000296:	00000097          	auipc	ra,0x0
    8000029a:	542080e7          	jalr	1346(ra) # 800007d8 <uartputc_sync>
    8000029e:	4521                	li	a0,8
    800002a0:	00000097          	auipc	ra,0x0
    800002a4:	538080e7          	jalr	1336(ra) # 800007d8 <uartputc_sync>
    800002a8:	bfe1                	j	80000280 <consputc+0x18>

00000000800002aa <consoleintr>:
// do erase/kill processing, append to cons.buf,
// wake up consoleread() if a whole line has arrived.
//
void
consoleintr(int c)
{
    800002aa:	1101                	addi	sp,sp,-32
    800002ac:	ec06                	sd	ra,24(sp)
    800002ae:	e822                	sd	s0,16(sp)
    800002b0:	e426                	sd	s1,8(sp)
    800002b2:	e04a                	sd	s2,0(sp)
    800002b4:	1000                	addi	s0,sp,32
    800002b6:	84aa                	mv	s1,a0
  acquire(&cons.lock);
    800002b8:	00011517          	auipc	a0,0x11
    800002bc:	ec850513          	addi	a0,a0,-312 # 80011180 <cons>
    800002c0:	00001097          	auipc	ra,0x1
    800002c4:	902080e7          	jalr	-1790(ra) # 80000bc2 <acquire>

  switch(c){
    800002c8:	47d5                	li	a5,21
    800002ca:	0af48663          	beq	s1,a5,80000376 <consoleintr+0xcc>
    800002ce:	0297ca63          	blt	a5,s1,80000302 <consoleintr+0x58>
    800002d2:	47a1                	li	a5,8
    800002d4:	0ef48763          	beq	s1,a5,800003c2 <consoleintr+0x118>
    800002d8:	47c1                	li	a5,16
    800002da:	10f49a63          	bne	s1,a5,800003ee <consoleintr+0x144>
  case C('P'):  // Print process list.
    procdump();
    800002de:	00002097          	auipc	ra,0x2
    800002e2:	1ea080e7          	jalr	490(ra) # 800024c8 <procdump>
      }
    }
    break;
  }
  
  release(&cons.lock);
    800002e6:	00011517          	auipc	a0,0x11
    800002ea:	e9a50513          	addi	a0,a0,-358 # 80011180 <cons>
    800002ee:	00001097          	auipc	ra,0x1
    800002f2:	988080e7          	jalr	-1656(ra) # 80000c76 <release>
}
    800002f6:	60e2                	ld	ra,24(sp)
    800002f8:	6442                	ld	s0,16(sp)
    800002fa:	64a2                	ld	s1,8(sp)
    800002fc:	6902                	ld	s2,0(sp)
    800002fe:	6105                	addi	sp,sp,32
    80000300:	8082                	ret
  switch(c){
    80000302:	07f00793          	li	a5,127
    80000306:	0af48e63          	beq	s1,a5,800003c2 <consoleintr+0x118>
    if(c != 0 && cons.e-cons.r < INPUT_BUF){
    8000030a:	00011717          	auipc	a4,0x11
    8000030e:	e7670713          	addi	a4,a4,-394 # 80011180 <cons>
    80000312:	0a072783          	lw	a5,160(a4)
    80000316:	09872703          	lw	a4,152(a4)
    8000031a:	9f99                	subw	a5,a5,a4
    8000031c:	07f00713          	li	a4,127
    80000320:	fcf763e3          	bltu	a4,a5,800002e6 <consoleintr+0x3c>
      c = (c == '\r') ? '\n' : c;
    80000324:	47b5                	li	a5,13
    80000326:	0cf48763          	beq	s1,a5,800003f4 <consoleintr+0x14a>
      consputc(c);
    8000032a:	8526                	mv	a0,s1
    8000032c:	00000097          	auipc	ra,0x0
    80000330:	f3c080e7          	jalr	-196(ra) # 80000268 <consputc>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    80000334:	00011797          	auipc	a5,0x11
    80000338:	e4c78793          	addi	a5,a5,-436 # 80011180 <cons>
    8000033c:	0a07a703          	lw	a4,160(a5)
    80000340:	0017069b          	addiw	a3,a4,1
    80000344:	0006861b          	sext.w	a2,a3
    80000348:	0ad7a023          	sw	a3,160(a5)
    8000034c:	07f77713          	andi	a4,a4,127
    80000350:	97ba                	add	a5,a5,a4
    80000352:	00978c23          	sb	s1,24(a5)
      if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
    80000356:	47a9                	li	a5,10
    80000358:	0cf48563          	beq	s1,a5,80000422 <consoleintr+0x178>
    8000035c:	4791                	li	a5,4
    8000035e:	0cf48263          	beq	s1,a5,80000422 <consoleintr+0x178>
    80000362:	00011797          	auipc	a5,0x11
    80000366:	eb67a783          	lw	a5,-330(a5) # 80011218 <cons+0x98>
    8000036a:	0807879b          	addiw	a5,a5,128
    8000036e:	f6f61ce3          	bne	a2,a5,800002e6 <consoleintr+0x3c>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    80000372:	863e                	mv	a2,a5
    80000374:	a07d                	j	80000422 <consoleintr+0x178>
    while(cons.e != cons.w &&
    80000376:	00011717          	auipc	a4,0x11
    8000037a:	e0a70713          	addi	a4,a4,-502 # 80011180 <cons>
    8000037e:	0a072783          	lw	a5,160(a4)
    80000382:	09c72703          	lw	a4,156(a4)
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    80000386:	00011497          	auipc	s1,0x11
    8000038a:	dfa48493          	addi	s1,s1,-518 # 80011180 <cons>
    while(cons.e != cons.w &&
    8000038e:	4929                	li	s2,10
    80000390:	f4f70be3          	beq	a4,a5,800002e6 <consoleintr+0x3c>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    80000394:	37fd                	addiw	a5,a5,-1
    80000396:	07f7f713          	andi	a4,a5,127
    8000039a:	9726                	add	a4,a4,s1
    while(cons.e != cons.w &&
    8000039c:	01874703          	lbu	a4,24(a4)
    800003a0:	f52703e3          	beq	a4,s2,800002e6 <consoleintr+0x3c>
      cons.e--;
    800003a4:	0af4a023          	sw	a5,160(s1)
      consputc(BACKSPACE);
    800003a8:	10000513          	li	a0,256
    800003ac:	00000097          	auipc	ra,0x0
    800003b0:	ebc080e7          	jalr	-324(ra) # 80000268 <consputc>
    while(cons.e != cons.w &&
    800003b4:	0a04a783          	lw	a5,160(s1)
    800003b8:	09c4a703          	lw	a4,156(s1)
    800003bc:	fcf71ce3          	bne	a4,a5,80000394 <consoleintr+0xea>
    800003c0:	b71d                	j	800002e6 <consoleintr+0x3c>
    if(cons.e != cons.w){
    800003c2:	00011717          	auipc	a4,0x11
    800003c6:	dbe70713          	addi	a4,a4,-578 # 80011180 <cons>
    800003ca:	0a072783          	lw	a5,160(a4)
    800003ce:	09c72703          	lw	a4,156(a4)
    800003d2:	f0f70ae3          	beq	a4,a5,800002e6 <consoleintr+0x3c>
      cons.e--;
    800003d6:	37fd                	addiw	a5,a5,-1
    800003d8:	00011717          	auipc	a4,0x11
    800003dc:	e4f72423          	sw	a5,-440(a4) # 80011220 <cons+0xa0>
      consputc(BACKSPACE);
    800003e0:	10000513          	li	a0,256
    800003e4:	00000097          	auipc	ra,0x0
    800003e8:	e84080e7          	jalr	-380(ra) # 80000268 <consputc>
    800003ec:	bded                	j	800002e6 <consoleintr+0x3c>
    if(c != 0 && cons.e-cons.r < INPUT_BUF){
    800003ee:	ee048ce3          	beqz	s1,800002e6 <consoleintr+0x3c>
    800003f2:	bf21                	j	8000030a <consoleintr+0x60>
      consputc(c);
    800003f4:	4529                	li	a0,10
    800003f6:	00000097          	auipc	ra,0x0
    800003fa:	e72080e7          	jalr	-398(ra) # 80000268 <consputc>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    800003fe:	00011797          	auipc	a5,0x11
    80000402:	d8278793          	addi	a5,a5,-638 # 80011180 <cons>
    80000406:	0a07a703          	lw	a4,160(a5)
    8000040a:	0017069b          	addiw	a3,a4,1
    8000040e:	0006861b          	sext.w	a2,a3
    80000412:	0ad7a023          	sw	a3,160(a5)
    80000416:	07f77713          	andi	a4,a4,127
    8000041a:	97ba                	add	a5,a5,a4
    8000041c:	4729                	li	a4,10
    8000041e:	00e78c23          	sb	a4,24(a5)
        cons.w = cons.e;
    80000422:	00011797          	auipc	a5,0x11
    80000426:	dec7ad23          	sw	a2,-518(a5) # 8001121c <cons+0x9c>
        wakeup(&cons.r);
    8000042a:	00011517          	auipc	a0,0x11
    8000042e:	dee50513          	addi	a0,a0,-530 # 80011218 <cons+0x98>
    80000432:	00002097          	auipc	ra,0x2
    80000436:	f10080e7          	jalr	-240(ra) # 80002342 <wakeup>
    8000043a:	b575                	j	800002e6 <consoleintr+0x3c>

000000008000043c <consoleinit>:

void
consoleinit(void)
{
    8000043c:	1141                	addi	sp,sp,-16
    8000043e:	e406                	sd	ra,8(sp)
    80000440:	e022                	sd	s0,0(sp)
    80000442:	0800                	addi	s0,sp,16
  initlock(&cons.lock, "cons");
    80000444:	00008597          	auipc	a1,0x8
    80000448:	bcc58593          	addi	a1,a1,-1076 # 80008010 <etext+0x10>
    8000044c:	00011517          	auipc	a0,0x11
    80000450:	d3450513          	addi	a0,a0,-716 # 80011180 <cons>
    80000454:	00000097          	auipc	ra,0x0
    80000458:	6de080e7          	jalr	1758(ra) # 80000b32 <initlock>

  uartinit();
    8000045c:	00000097          	auipc	ra,0x0
    80000460:	32c080e7          	jalr	812(ra) # 80000788 <uartinit>

  // connect read and write system calls
  // to consoleread and consolewrite.
  devsw[CONSOLE].read = consoleread;
    80000464:	0001c797          	auipc	a5,0x1c
    80000468:	2ac78793          	addi	a5,a5,684 # 8001c710 <devsw>
    8000046c:	00000717          	auipc	a4,0x0
    80000470:	cea70713          	addi	a4,a4,-790 # 80000156 <consoleread>
    80000474:	eb98                	sd	a4,16(a5)
  devsw[CONSOLE].write = consolewrite;
    80000476:	00000717          	auipc	a4,0x0
    8000047a:	c7c70713          	addi	a4,a4,-900 # 800000f2 <consolewrite>
    8000047e:	ef98                	sd	a4,24(a5)
}
    80000480:	60a2                	ld	ra,8(sp)
    80000482:	6402                	ld	s0,0(sp)
    80000484:	0141                	addi	sp,sp,16
    80000486:	8082                	ret

0000000080000488 <printint>:

static char digits[] = "0123456789abcdef";

static void
printint(int xx, int base, int sign)
{
    80000488:	7179                	addi	sp,sp,-48
    8000048a:	f406                	sd	ra,40(sp)
    8000048c:	f022                	sd	s0,32(sp)
    8000048e:	ec26                	sd	s1,24(sp)
    80000490:	e84a                	sd	s2,16(sp)
    80000492:	1800                	addi	s0,sp,48
  char buf[16];
  int i;
  uint x;

  if(sign && (sign = xx < 0))
    80000494:	c219                	beqz	a2,8000049a <printint+0x12>
    80000496:	08054763          	bltz	a0,80000524 <printint+0x9c>
    x = -xx;
  else
    x = xx;
    8000049a:	2501                	sext.w	a0,a0
    8000049c:	4881                	li	a7,0
    8000049e:	fd040693          	addi	a3,s0,-48

  i = 0;
    800004a2:	4701                	li	a4,0
  do {
    buf[i++] = digits[x % base];
    800004a4:	2581                	sext.w	a1,a1
    800004a6:	00008617          	auipc	a2,0x8
    800004aa:	b9a60613          	addi	a2,a2,-1126 # 80008040 <digits>
    800004ae:	883a                	mv	a6,a4
    800004b0:	2705                	addiw	a4,a4,1
    800004b2:	02b577bb          	remuw	a5,a0,a1
    800004b6:	1782                	slli	a5,a5,0x20
    800004b8:	9381                	srli	a5,a5,0x20
    800004ba:	97b2                	add	a5,a5,a2
    800004bc:	0007c783          	lbu	a5,0(a5)
    800004c0:	00f68023          	sb	a5,0(a3)
  } while((x /= base) != 0);
    800004c4:	0005079b          	sext.w	a5,a0
    800004c8:	02b5553b          	divuw	a0,a0,a1
    800004cc:	0685                	addi	a3,a3,1
    800004ce:	feb7f0e3          	bgeu	a5,a1,800004ae <printint+0x26>

  if(sign)
    800004d2:	00088c63          	beqz	a7,800004ea <printint+0x62>
    buf[i++] = '-';
    800004d6:	fe070793          	addi	a5,a4,-32
    800004da:	00878733          	add	a4,a5,s0
    800004de:	02d00793          	li	a5,45
    800004e2:	fef70823          	sb	a5,-16(a4)
    800004e6:	0028071b          	addiw	a4,a6,2

  while(--i >= 0)
    800004ea:	02e05763          	blez	a4,80000518 <printint+0x90>
    800004ee:	fd040793          	addi	a5,s0,-48
    800004f2:	00e784b3          	add	s1,a5,a4
    800004f6:	fff78913          	addi	s2,a5,-1
    800004fa:	993a                	add	s2,s2,a4
    800004fc:	377d                	addiw	a4,a4,-1
    800004fe:	1702                	slli	a4,a4,0x20
    80000500:	9301                	srli	a4,a4,0x20
    80000502:	40e90933          	sub	s2,s2,a4
    consputc(buf[i]);
    80000506:	fff4c503          	lbu	a0,-1(s1)
    8000050a:	00000097          	auipc	ra,0x0
    8000050e:	d5e080e7          	jalr	-674(ra) # 80000268 <consputc>
  while(--i >= 0)
    80000512:	14fd                	addi	s1,s1,-1
    80000514:	ff2499e3          	bne	s1,s2,80000506 <printint+0x7e>
}
    80000518:	70a2                	ld	ra,40(sp)
    8000051a:	7402                	ld	s0,32(sp)
    8000051c:	64e2                	ld	s1,24(sp)
    8000051e:	6942                	ld	s2,16(sp)
    80000520:	6145                	addi	sp,sp,48
    80000522:	8082                	ret
    x = -xx;
    80000524:	40a0053b          	negw	a0,a0
  if(sign && (sign = xx < 0))
    80000528:	4885                	li	a7,1
    x = -xx;
    8000052a:	bf95                	j	8000049e <printint+0x16>

000000008000052c <panic>:
    release(&pr.lock);
}

void
panic(char *s)
{
    8000052c:	1101                	addi	sp,sp,-32
    8000052e:	ec06                	sd	ra,24(sp)
    80000530:	e822                	sd	s0,16(sp)
    80000532:	e426                	sd	s1,8(sp)
    80000534:	1000                	addi	s0,sp,32
    80000536:	84aa                	mv	s1,a0
  pr.locking = 0;
    80000538:	00011797          	auipc	a5,0x11
    8000053c:	d007a423          	sw	zero,-760(a5) # 80011240 <pr+0x18>
  printf("panic: ");
    80000540:	00008517          	auipc	a0,0x8
    80000544:	ad850513          	addi	a0,a0,-1320 # 80008018 <etext+0x18>
    80000548:	00000097          	auipc	ra,0x0
    8000054c:	02e080e7          	jalr	46(ra) # 80000576 <printf>
  printf(s);
    80000550:	8526                	mv	a0,s1
    80000552:	00000097          	auipc	ra,0x0
    80000556:	024080e7          	jalr	36(ra) # 80000576 <printf>
  printf("\n");
    8000055a:	00008517          	auipc	a0,0x8
    8000055e:	b6e50513          	addi	a0,a0,-1170 # 800080c8 <digits+0x88>
    80000562:	00000097          	auipc	ra,0x0
    80000566:	014080e7          	jalr	20(ra) # 80000576 <printf>
  panicked = 1; // freeze uart output from other CPUs
    8000056a:	4785                	li	a5,1
    8000056c:	00009717          	auipc	a4,0x9
    80000570:	a8f72a23          	sw	a5,-1388(a4) # 80009000 <panicked>
  for(;;)
    80000574:	a001                	j	80000574 <panic+0x48>

0000000080000576 <printf>:
{
    80000576:	7131                	addi	sp,sp,-192
    80000578:	fc86                	sd	ra,120(sp)
    8000057a:	f8a2                	sd	s0,112(sp)
    8000057c:	f4a6                	sd	s1,104(sp)
    8000057e:	f0ca                	sd	s2,96(sp)
    80000580:	ecce                	sd	s3,88(sp)
    80000582:	e8d2                	sd	s4,80(sp)
    80000584:	e4d6                	sd	s5,72(sp)
    80000586:	e0da                	sd	s6,64(sp)
    80000588:	fc5e                	sd	s7,56(sp)
    8000058a:	f862                	sd	s8,48(sp)
    8000058c:	f466                	sd	s9,40(sp)
    8000058e:	f06a                	sd	s10,32(sp)
    80000590:	ec6e                	sd	s11,24(sp)
    80000592:	0100                	addi	s0,sp,128
    80000594:	8a2a                	mv	s4,a0
    80000596:	e40c                	sd	a1,8(s0)
    80000598:	e810                	sd	a2,16(s0)
    8000059a:	ec14                	sd	a3,24(s0)
    8000059c:	f018                	sd	a4,32(s0)
    8000059e:	f41c                	sd	a5,40(s0)
    800005a0:	03043823          	sd	a6,48(s0)
    800005a4:	03143c23          	sd	a7,56(s0)
  locking = pr.locking;
    800005a8:	00011d97          	auipc	s11,0x11
    800005ac:	c98dad83          	lw	s11,-872(s11) # 80011240 <pr+0x18>
  if(locking)
    800005b0:	020d9b63          	bnez	s11,800005e6 <printf+0x70>
  if (fmt == 0)
    800005b4:	040a0263          	beqz	s4,800005f8 <printf+0x82>
  va_start(ap, fmt);
    800005b8:	00840793          	addi	a5,s0,8
    800005bc:	f8f43423          	sd	a5,-120(s0)
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    800005c0:	000a4503          	lbu	a0,0(s4)
    800005c4:	14050f63          	beqz	a0,80000722 <printf+0x1ac>
    800005c8:	4981                	li	s3,0
    if(c != '%'){
    800005ca:	02500a93          	li	s5,37
    switch(c){
    800005ce:	07000b93          	li	s7,112
  consputc('x');
    800005d2:	4d41                	li	s10,16
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    800005d4:	00008b17          	auipc	s6,0x8
    800005d8:	a6cb0b13          	addi	s6,s6,-1428 # 80008040 <digits>
    switch(c){
    800005dc:	07300c93          	li	s9,115
    800005e0:	06400c13          	li	s8,100
    800005e4:	a82d                	j	8000061e <printf+0xa8>
    acquire(&pr.lock);
    800005e6:	00011517          	auipc	a0,0x11
    800005ea:	c4250513          	addi	a0,a0,-958 # 80011228 <pr>
    800005ee:	00000097          	auipc	ra,0x0
    800005f2:	5d4080e7          	jalr	1492(ra) # 80000bc2 <acquire>
    800005f6:	bf7d                	j	800005b4 <printf+0x3e>
    panic("null fmt");
    800005f8:	00008517          	auipc	a0,0x8
    800005fc:	a3050513          	addi	a0,a0,-1488 # 80008028 <etext+0x28>
    80000600:	00000097          	auipc	ra,0x0
    80000604:	f2c080e7          	jalr	-212(ra) # 8000052c <panic>
      consputc(c);
    80000608:	00000097          	auipc	ra,0x0
    8000060c:	c60080e7          	jalr	-928(ra) # 80000268 <consputc>
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    80000610:	2985                	addiw	s3,s3,1
    80000612:	013a07b3          	add	a5,s4,s3
    80000616:	0007c503          	lbu	a0,0(a5)
    8000061a:	10050463          	beqz	a0,80000722 <printf+0x1ac>
    if(c != '%'){
    8000061e:	ff5515e3          	bne	a0,s5,80000608 <printf+0x92>
    c = fmt[++i] & 0xff;
    80000622:	2985                	addiw	s3,s3,1
    80000624:	013a07b3          	add	a5,s4,s3
    80000628:	0007c783          	lbu	a5,0(a5)
    8000062c:	0007849b          	sext.w	s1,a5
    if(c == 0)
    80000630:	cbed                	beqz	a5,80000722 <printf+0x1ac>
    switch(c){
    80000632:	05778a63          	beq	a5,s7,80000686 <printf+0x110>
    80000636:	02fbf663          	bgeu	s7,a5,80000662 <printf+0xec>
    8000063a:	09978863          	beq	a5,s9,800006ca <printf+0x154>
    8000063e:	07800713          	li	a4,120
    80000642:	0ce79563          	bne	a5,a4,8000070c <printf+0x196>
      printint(va_arg(ap, int), 16, 1);
    80000646:	f8843783          	ld	a5,-120(s0)
    8000064a:	00878713          	addi	a4,a5,8
    8000064e:	f8e43423          	sd	a4,-120(s0)
    80000652:	4605                	li	a2,1
    80000654:	85ea                	mv	a1,s10
    80000656:	4388                	lw	a0,0(a5)
    80000658:	00000097          	auipc	ra,0x0
    8000065c:	e30080e7          	jalr	-464(ra) # 80000488 <printint>
      break;
    80000660:	bf45                	j	80000610 <printf+0x9a>
    switch(c){
    80000662:	09578f63          	beq	a5,s5,80000700 <printf+0x18a>
    80000666:	0b879363          	bne	a5,s8,8000070c <printf+0x196>
      printint(va_arg(ap, int), 10, 1);
    8000066a:	f8843783          	ld	a5,-120(s0)
    8000066e:	00878713          	addi	a4,a5,8
    80000672:	f8e43423          	sd	a4,-120(s0)
    80000676:	4605                	li	a2,1
    80000678:	45a9                	li	a1,10
    8000067a:	4388                	lw	a0,0(a5)
    8000067c:	00000097          	auipc	ra,0x0
    80000680:	e0c080e7          	jalr	-500(ra) # 80000488 <printint>
      break;
    80000684:	b771                	j	80000610 <printf+0x9a>
      printptr(va_arg(ap, uint64));
    80000686:	f8843783          	ld	a5,-120(s0)
    8000068a:	00878713          	addi	a4,a5,8
    8000068e:	f8e43423          	sd	a4,-120(s0)
    80000692:	0007b903          	ld	s2,0(a5)
  consputc('0');
    80000696:	03000513          	li	a0,48
    8000069a:	00000097          	auipc	ra,0x0
    8000069e:	bce080e7          	jalr	-1074(ra) # 80000268 <consputc>
  consputc('x');
    800006a2:	07800513          	li	a0,120
    800006a6:	00000097          	auipc	ra,0x0
    800006aa:	bc2080e7          	jalr	-1086(ra) # 80000268 <consputc>
    800006ae:	84ea                	mv	s1,s10
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    800006b0:	03c95793          	srli	a5,s2,0x3c
    800006b4:	97da                	add	a5,a5,s6
    800006b6:	0007c503          	lbu	a0,0(a5)
    800006ba:	00000097          	auipc	ra,0x0
    800006be:	bae080e7          	jalr	-1106(ra) # 80000268 <consputc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
    800006c2:	0912                	slli	s2,s2,0x4
    800006c4:	34fd                	addiw	s1,s1,-1
    800006c6:	f4ed                	bnez	s1,800006b0 <printf+0x13a>
    800006c8:	b7a1                	j	80000610 <printf+0x9a>
      if((s = va_arg(ap, char*)) == 0)
    800006ca:	f8843783          	ld	a5,-120(s0)
    800006ce:	00878713          	addi	a4,a5,8
    800006d2:	f8e43423          	sd	a4,-120(s0)
    800006d6:	6384                	ld	s1,0(a5)
    800006d8:	cc89                	beqz	s1,800006f2 <printf+0x17c>
      for(; *s; s++)
    800006da:	0004c503          	lbu	a0,0(s1)
    800006de:	d90d                	beqz	a0,80000610 <printf+0x9a>
        consputc(*s);
    800006e0:	00000097          	auipc	ra,0x0
    800006e4:	b88080e7          	jalr	-1144(ra) # 80000268 <consputc>
      for(; *s; s++)
    800006e8:	0485                	addi	s1,s1,1
    800006ea:	0004c503          	lbu	a0,0(s1)
    800006ee:	f96d                	bnez	a0,800006e0 <printf+0x16a>
    800006f0:	b705                	j	80000610 <printf+0x9a>
        s = "(null)";
    800006f2:	00008497          	auipc	s1,0x8
    800006f6:	92e48493          	addi	s1,s1,-1746 # 80008020 <etext+0x20>
      for(; *s; s++)
    800006fa:	02800513          	li	a0,40
    800006fe:	b7cd                	j	800006e0 <printf+0x16a>
      consputc('%');
    80000700:	8556                	mv	a0,s5
    80000702:	00000097          	auipc	ra,0x0
    80000706:	b66080e7          	jalr	-1178(ra) # 80000268 <consputc>
      break;
    8000070a:	b719                	j	80000610 <printf+0x9a>
      consputc('%');
    8000070c:	8556                	mv	a0,s5
    8000070e:	00000097          	auipc	ra,0x0
    80000712:	b5a080e7          	jalr	-1190(ra) # 80000268 <consputc>
      consputc(c);
    80000716:	8526                	mv	a0,s1
    80000718:	00000097          	auipc	ra,0x0
    8000071c:	b50080e7          	jalr	-1200(ra) # 80000268 <consputc>
      break;
    80000720:	bdc5                	j	80000610 <printf+0x9a>
  if(locking)
    80000722:	020d9163          	bnez	s11,80000744 <printf+0x1ce>
}
    80000726:	70e6                	ld	ra,120(sp)
    80000728:	7446                	ld	s0,112(sp)
    8000072a:	74a6                	ld	s1,104(sp)
    8000072c:	7906                	ld	s2,96(sp)
    8000072e:	69e6                	ld	s3,88(sp)
    80000730:	6a46                	ld	s4,80(sp)
    80000732:	6aa6                	ld	s5,72(sp)
    80000734:	6b06                	ld	s6,64(sp)
    80000736:	7be2                	ld	s7,56(sp)
    80000738:	7c42                	ld	s8,48(sp)
    8000073a:	7ca2                	ld	s9,40(sp)
    8000073c:	7d02                	ld	s10,32(sp)
    8000073e:	6de2                	ld	s11,24(sp)
    80000740:	6129                	addi	sp,sp,192
    80000742:	8082                	ret
    release(&pr.lock);
    80000744:	00011517          	auipc	a0,0x11
    80000748:	ae450513          	addi	a0,a0,-1308 # 80011228 <pr>
    8000074c:	00000097          	auipc	ra,0x0
    80000750:	52a080e7          	jalr	1322(ra) # 80000c76 <release>
}
    80000754:	bfc9                	j	80000726 <printf+0x1b0>

0000000080000756 <printfinit>:
    ;
}

void
printfinit(void)
{
    80000756:	1101                	addi	sp,sp,-32
    80000758:	ec06                	sd	ra,24(sp)
    8000075a:	e822                	sd	s0,16(sp)
    8000075c:	e426                	sd	s1,8(sp)
    8000075e:	1000                	addi	s0,sp,32
  initlock(&pr.lock, "pr");
    80000760:	00011497          	auipc	s1,0x11
    80000764:	ac848493          	addi	s1,s1,-1336 # 80011228 <pr>
    80000768:	00008597          	auipc	a1,0x8
    8000076c:	8d058593          	addi	a1,a1,-1840 # 80008038 <etext+0x38>
    80000770:	8526                	mv	a0,s1
    80000772:	00000097          	auipc	ra,0x0
    80000776:	3c0080e7          	jalr	960(ra) # 80000b32 <initlock>
  pr.locking = 1;
    8000077a:	4785                	li	a5,1
    8000077c:	cc9c                	sw	a5,24(s1)
}
    8000077e:	60e2                	ld	ra,24(sp)
    80000780:	6442                	ld	s0,16(sp)
    80000782:	64a2                	ld	s1,8(sp)
    80000784:	6105                	addi	sp,sp,32
    80000786:	8082                	ret

0000000080000788 <uartinit>:

void uartstart();

void
uartinit(void)
{
    80000788:	1141                	addi	sp,sp,-16
    8000078a:	e406                	sd	ra,8(sp)
    8000078c:	e022                	sd	s0,0(sp)
    8000078e:	0800                	addi	s0,sp,16
  // disable interrupts.
  WriteReg(IER, 0x00);
    80000790:	100007b7          	lui	a5,0x10000
    80000794:	000780a3          	sb	zero,1(a5) # 10000001 <_entry-0x6fffffff>

  // special mode to set baud rate.
  WriteReg(LCR, LCR_BAUD_LATCH);
    80000798:	f8000713          	li	a4,-128
    8000079c:	00e781a3          	sb	a4,3(a5)

  // LSB for baud rate of 38.4K.
  WriteReg(0, 0x03);
    800007a0:	470d                	li	a4,3
    800007a2:	00e78023          	sb	a4,0(a5)

  // MSB for baud rate of 38.4K.
  WriteReg(1, 0x00);
    800007a6:	000780a3          	sb	zero,1(a5)

  // leave set-baud mode,
  // and set word length to 8 bits, no parity.
  WriteReg(LCR, LCR_EIGHT_BITS);
    800007aa:	00e781a3          	sb	a4,3(a5)

  // reset and enable FIFOs.
  WriteReg(FCR, FCR_FIFO_ENABLE | FCR_FIFO_CLEAR);
    800007ae:	469d                	li	a3,7
    800007b0:	00d78123          	sb	a3,2(a5)

  // enable transmit and receive interrupts.
  WriteReg(IER, IER_TX_ENABLE | IER_RX_ENABLE);
    800007b4:	00e780a3          	sb	a4,1(a5)

  initlock(&uart_tx_lock, "uart");
    800007b8:	00008597          	auipc	a1,0x8
    800007bc:	8a058593          	addi	a1,a1,-1888 # 80008058 <digits+0x18>
    800007c0:	00011517          	auipc	a0,0x11
    800007c4:	a8850513          	addi	a0,a0,-1400 # 80011248 <uart_tx_lock>
    800007c8:	00000097          	auipc	ra,0x0
    800007cc:	36a080e7          	jalr	874(ra) # 80000b32 <initlock>
}
    800007d0:	60a2                	ld	ra,8(sp)
    800007d2:	6402                	ld	s0,0(sp)
    800007d4:	0141                	addi	sp,sp,16
    800007d6:	8082                	ret

00000000800007d8 <uartputc_sync>:
// use interrupts, for use by kernel printf() and
// to echo characters. it spins waiting for the uart's
// output register to be empty.
void
uartputc_sync(int c)
{
    800007d8:	1101                	addi	sp,sp,-32
    800007da:	ec06                	sd	ra,24(sp)
    800007dc:	e822                	sd	s0,16(sp)
    800007de:	e426                	sd	s1,8(sp)
    800007e0:	1000                	addi	s0,sp,32
    800007e2:	84aa                	mv	s1,a0
  push_off();
    800007e4:	00000097          	auipc	ra,0x0
    800007e8:	392080e7          	jalr	914(ra) # 80000b76 <push_off>

  if(panicked){
    800007ec:	00009797          	auipc	a5,0x9
    800007f0:	8147a783          	lw	a5,-2028(a5) # 80009000 <panicked>
    for(;;)
      ;
  }

  // wait for Transmit Holding Empty to be set in LSR.
  while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
    800007f4:	10000737          	lui	a4,0x10000
  if(panicked){
    800007f8:	c391                	beqz	a5,800007fc <uartputc_sync+0x24>
    for(;;)
    800007fa:	a001                	j	800007fa <uartputc_sync+0x22>
  while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
    800007fc:	00574783          	lbu	a5,5(a4) # 10000005 <_entry-0x6ffffffb>
    80000800:	0207f793          	andi	a5,a5,32
    80000804:	dfe5                	beqz	a5,800007fc <uartputc_sync+0x24>
    ;
  WriteReg(THR, c);
    80000806:	0ff4f513          	zext.b	a0,s1
    8000080a:	100007b7          	lui	a5,0x10000
    8000080e:	00a78023          	sb	a0,0(a5) # 10000000 <_entry-0x70000000>

  pop_off();
    80000812:	00000097          	auipc	ra,0x0
    80000816:	404080e7          	jalr	1028(ra) # 80000c16 <pop_off>
}
    8000081a:	60e2                	ld	ra,24(sp)
    8000081c:	6442                	ld	s0,16(sp)
    8000081e:	64a2                	ld	s1,8(sp)
    80000820:	6105                	addi	sp,sp,32
    80000822:	8082                	ret

0000000080000824 <uartstart>:
// called from both the top- and bottom-half.
void
uartstart()
{
  while(1){
    if(uart_tx_w == uart_tx_r){
    80000824:	00008797          	auipc	a5,0x8
    80000828:	7e47b783          	ld	a5,2020(a5) # 80009008 <uart_tx_r>
    8000082c:	00008717          	auipc	a4,0x8
    80000830:	7e473703          	ld	a4,2020(a4) # 80009010 <uart_tx_w>
    80000834:	06f70a63          	beq	a4,a5,800008a8 <uartstart+0x84>
{
    80000838:	7139                	addi	sp,sp,-64
    8000083a:	fc06                	sd	ra,56(sp)
    8000083c:	f822                	sd	s0,48(sp)
    8000083e:	f426                	sd	s1,40(sp)
    80000840:	f04a                	sd	s2,32(sp)
    80000842:	ec4e                	sd	s3,24(sp)
    80000844:	e852                	sd	s4,16(sp)
    80000846:	e456                	sd	s5,8(sp)
    80000848:	0080                	addi	s0,sp,64
      // transmit buffer is empty.
      return;
    }
    
    if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
    8000084a:	10000937          	lui	s2,0x10000
      // so we cannot give it another byte.
      // it will interrupt when it's ready for a new byte.
      return;
    }
    
    int c = uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE];
    8000084e:	00011a17          	auipc	s4,0x11
    80000852:	9faa0a13          	addi	s4,s4,-1542 # 80011248 <uart_tx_lock>
    uart_tx_r += 1;
    80000856:	00008497          	auipc	s1,0x8
    8000085a:	7b248493          	addi	s1,s1,1970 # 80009008 <uart_tx_r>
    if(uart_tx_w == uart_tx_r){
    8000085e:	00008997          	auipc	s3,0x8
    80000862:	7b298993          	addi	s3,s3,1970 # 80009010 <uart_tx_w>
    if((ReadReg(LSR) & LSR_TX_IDLE) == 0){
    80000866:	00594703          	lbu	a4,5(s2) # 10000005 <_entry-0x6ffffffb>
    8000086a:	02077713          	andi	a4,a4,32
    8000086e:	c705                	beqz	a4,80000896 <uartstart+0x72>
    int c = uart_tx_buf[uart_tx_r % UART_TX_BUF_SIZE];
    80000870:	01f7f713          	andi	a4,a5,31
    80000874:	9752                	add	a4,a4,s4
    80000876:	01874a83          	lbu	s5,24(a4)
    uart_tx_r += 1;
    8000087a:	0785                	addi	a5,a5,1
    8000087c:	e09c                	sd	a5,0(s1)
    
    // maybe uartputc() is waiting for space in the buffer.
    wakeup(&uart_tx_r);
    8000087e:	8526                	mv	a0,s1
    80000880:	00002097          	auipc	ra,0x2
    80000884:	ac2080e7          	jalr	-1342(ra) # 80002342 <wakeup>
    
    WriteReg(THR, c);
    80000888:	01590023          	sb	s5,0(s2)
    if(uart_tx_w == uart_tx_r){
    8000088c:	609c                	ld	a5,0(s1)
    8000088e:	0009b703          	ld	a4,0(s3)
    80000892:	fcf71ae3          	bne	a4,a5,80000866 <uartstart+0x42>
  }
}
    80000896:	70e2                	ld	ra,56(sp)
    80000898:	7442                	ld	s0,48(sp)
    8000089a:	74a2                	ld	s1,40(sp)
    8000089c:	7902                	ld	s2,32(sp)
    8000089e:	69e2                	ld	s3,24(sp)
    800008a0:	6a42                	ld	s4,16(sp)
    800008a2:	6aa2                	ld	s5,8(sp)
    800008a4:	6121                	addi	sp,sp,64
    800008a6:	8082                	ret
    800008a8:	8082                	ret

00000000800008aa <uartputc>:
{
    800008aa:	7179                	addi	sp,sp,-48
    800008ac:	f406                	sd	ra,40(sp)
    800008ae:	f022                	sd	s0,32(sp)
    800008b0:	ec26                	sd	s1,24(sp)
    800008b2:	e84a                	sd	s2,16(sp)
    800008b4:	e44e                	sd	s3,8(sp)
    800008b6:	e052                	sd	s4,0(sp)
    800008b8:	1800                	addi	s0,sp,48
    800008ba:	8a2a                	mv	s4,a0
  acquire(&uart_tx_lock);
    800008bc:	00011517          	auipc	a0,0x11
    800008c0:	98c50513          	addi	a0,a0,-1652 # 80011248 <uart_tx_lock>
    800008c4:	00000097          	auipc	ra,0x0
    800008c8:	2fe080e7          	jalr	766(ra) # 80000bc2 <acquire>
  if(panicked){
    800008cc:	00008797          	auipc	a5,0x8
    800008d0:	7347a783          	lw	a5,1844(a5) # 80009000 <panicked>
    800008d4:	c391                	beqz	a5,800008d8 <uartputc+0x2e>
    for(;;)
    800008d6:	a001                	j	800008d6 <uartputc+0x2c>
    if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
    800008d8:	00008717          	auipc	a4,0x8
    800008dc:	73873703          	ld	a4,1848(a4) # 80009010 <uart_tx_w>
    800008e0:	00008797          	auipc	a5,0x8
    800008e4:	7287b783          	ld	a5,1832(a5) # 80009008 <uart_tx_r>
    800008e8:	02078793          	addi	a5,a5,32
    800008ec:	02e79b63          	bne	a5,a4,80000922 <uartputc+0x78>
      sleep(&uart_tx_r, &uart_tx_lock);
    800008f0:	00011997          	auipc	s3,0x11
    800008f4:	95898993          	addi	s3,s3,-1704 # 80011248 <uart_tx_lock>
    800008f8:	00008497          	auipc	s1,0x8
    800008fc:	71048493          	addi	s1,s1,1808 # 80009008 <uart_tx_r>
    if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
    80000900:	00008917          	auipc	s2,0x8
    80000904:	71090913          	addi	s2,s2,1808 # 80009010 <uart_tx_w>
      sleep(&uart_tx_r, &uart_tx_lock);
    80000908:	85ce                	mv	a1,s3
    8000090a:	8526                	mv	a0,s1
    8000090c:	00002097          	auipc	ra,0x2
    80000910:	8b6080e7          	jalr	-1866(ra) # 800021c2 <sleep>
    if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
    80000914:	00093703          	ld	a4,0(s2)
    80000918:	609c                	ld	a5,0(s1)
    8000091a:	02078793          	addi	a5,a5,32
    8000091e:	fee785e3          	beq	a5,a4,80000908 <uartputc+0x5e>
      uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
    80000922:	00011497          	auipc	s1,0x11
    80000926:	92648493          	addi	s1,s1,-1754 # 80011248 <uart_tx_lock>
    8000092a:	01f77793          	andi	a5,a4,31
    8000092e:	97a6                	add	a5,a5,s1
    80000930:	01478c23          	sb	s4,24(a5)
      uart_tx_w += 1;
    80000934:	0705                	addi	a4,a4,1
    80000936:	00008797          	auipc	a5,0x8
    8000093a:	6ce7bd23          	sd	a4,1754(a5) # 80009010 <uart_tx_w>
      uartstart();
    8000093e:	00000097          	auipc	ra,0x0
    80000942:	ee6080e7          	jalr	-282(ra) # 80000824 <uartstart>
      release(&uart_tx_lock);
    80000946:	8526                	mv	a0,s1
    80000948:	00000097          	auipc	ra,0x0
    8000094c:	32e080e7          	jalr	814(ra) # 80000c76 <release>
}
    80000950:	70a2                	ld	ra,40(sp)
    80000952:	7402                	ld	s0,32(sp)
    80000954:	64e2                	ld	s1,24(sp)
    80000956:	6942                	ld	s2,16(sp)
    80000958:	69a2                	ld	s3,8(sp)
    8000095a:	6a02                	ld	s4,0(sp)
    8000095c:	6145                	addi	sp,sp,48
    8000095e:	8082                	ret

0000000080000960 <uartgetc>:

// read one input character from the UART.
// return -1 if none is waiting.
int
uartgetc(void)
{
    80000960:	1141                	addi	sp,sp,-16
    80000962:	e422                	sd	s0,8(sp)
    80000964:	0800                	addi	s0,sp,16
  if(ReadReg(LSR) & 0x01){
    80000966:	100007b7          	lui	a5,0x10000
    8000096a:	0057c783          	lbu	a5,5(a5) # 10000005 <_entry-0x6ffffffb>
    8000096e:	8b85                	andi	a5,a5,1
    80000970:	cb81                	beqz	a5,80000980 <uartgetc+0x20>
    // input data is ready.
    return ReadReg(RHR);
    80000972:	100007b7          	lui	a5,0x10000
    80000976:	0007c503          	lbu	a0,0(a5) # 10000000 <_entry-0x70000000>
  } else {
    return -1;
  }
}
    8000097a:	6422                	ld	s0,8(sp)
    8000097c:	0141                	addi	sp,sp,16
    8000097e:	8082                	ret
    return -1;
    80000980:	557d                	li	a0,-1
    80000982:	bfe5                	j	8000097a <uartgetc+0x1a>

0000000080000984 <uartintr>:
// handle a uart interrupt, raised because input has
// arrived, or the uart is ready for more output, or
// both. called from trap.c.
void
uartintr(void)
{
    80000984:	1101                	addi	sp,sp,-32
    80000986:	ec06                	sd	ra,24(sp)
    80000988:	e822                	sd	s0,16(sp)
    8000098a:	e426                	sd	s1,8(sp)
    8000098c:	1000                	addi	s0,sp,32
  // read and process incoming characters.
  while(1){
    int c = uartgetc();
    if(c == -1)
    8000098e:	54fd                	li	s1,-1
    80000990:	a029                	j	8000099a <uartintr+0x16>
      break;
    consoleintr(c);
    80000992:	00000097          	auipc	ra,0x0
    80000996:	918080e7          	jalr	-1768(ra) # 800002aa <consoleintr>
    int c = uartgetc();
    8000099a:	00000097          	auipc	ra,0x0
    8000099e:	fc6080e7          	jalr	-58(ra) # 80000960 <uartgetc>
    if(c == -1)
    800009a2:	fe9518e3          	bne	a0,s1,80000992 <uartintr+0xe>
  }

  // send buffered characters.
  acquire(&uart_tx_lock);
    800009a6:	00011497          	auipc	s1,0x11
    800009aa:	8a248493          	addi	s1,s1,-1886 # 80011248 <uart_tx_lock>
    800009ae:	8526                	mv	a0,s1
    800009b0:	00000097          	auipc	ra,0x0
    800009b4:	212080e7          	jalr	530(ra) # 80000bc2 <acquire>
  uartstart();
    800009b8:	00000097          	auipc	ra,0x0
    800009bc:	e6c080e7          	jalr	-404(ra) # 80000824 <uartstart>
  release(&uart_tx_lock);
    800009c0:	8526                	mv	a0,s1
    800009c2:	00000097          	auipc	ra,0x0
    800009c6:	2b4080e7          	jalr	692(ra) # 80000c76 <release>
}
    800009ca:	60e2                	ld	ra,24(sp)
    800009cc:	6442                	ld	s0,16(sp)
    800009ce:	64a2                	ld	s1,8(sp)
    800009d0:	6105                	addi	sp,sp,32
    800009d2:	8082                	ret

00000000800009d4 <kfree>:
// which normally should have been returned by a
// call to kalloc().  (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(void *pa)
{
    800009d4:	1101                	addi	sp,sp,-32
    800009d6:	ec06                	sd	ra,24(sp)
    800009d8:	e822                	sd	s0,16(sp)
    800009da:	e426                	sd	s1,8(sp)
    800009dc:	e04a                	sd	s2,0(sp)
    800009de:	1000                	addi	s0,sp,32
  struct run *r;

  if(((uint64)pa % PGSIZE) != 0 || (char*)pa < end || (uint64)pa >= PHYSTOP)
    800009e0:	03451793          	slli	a5,a0,0x34
    800009e4:	ebb9                	bnez	a5,80000a3a <kfree+0x66>
    800009e6:	84aa                	mv	s1,a0
    800009e8:	00020797          	auipc	a5,0x20
    800009ec:	61878793          	addi	a5,a5,1560 # 80021000 <end>
    800009f0:	04f56563          	bltu	a0,a5,80000a3a <kfree+0x66>
    800009f4:	47c5                	li	a5,17
    800009f6:	07ee                	slli	a5,a5,0x1b
    800009f8:	04f57163          	bgeu	a0,a5,80000a3a <kfree+0x66>
    panic("kfree");

  // Fill with junk to catch dangling refs.
  memset(pa, 1, PGSIZE);
    800009fc:	6605                	lui	a2,0x1
    800009fe:	4585                	li	a1,1
    80000a00:	00000097          	auipc	ra,0x0
    80000a04:	2be080e7          	jalr	702(ra) # 80000cbe <memset>

  r = (struct run*)pa;

  acquire(&kmem.lock);
    80000a08:	00011917          	auipc	s2,0x11
    80000a0c:	87890913          	addi	s2,s2,-1928 # 80011280 <kmem>
    80000a10:	854a                	mv	a0,s2
    80000a12:	00000097          	auipc	ra,0x0
    80000a16:	1b0080e7          	jalr	432(ra) # 80000bc2 <acquire>
  r->next = kmem.freelist;
    80000a1a:	01893783          	ld	a5,24(s2)
    80000a1e:	e09c                	sd	a5,0(s1)
  kmem.freelist = r;
    80000a20:	00993c23          	sd	s1,24(s2)
  release(&kmem.lock);
    80000a24:	854a                	mv	a0,s2
    80000a26:	00000097          	auipc	ra,0x0
    80000a2a:	250080e7          	jalr	592(ra) # 80000c76 <release>
}
    80000a2e:	60e2                	ld	ra,24(sp)
    80000a30:	6442                	ld	s0,16(sp)
    80000a32:	64a2                	ld	s1,8(sp)
    80000a34:	6902                	ld	s2,0(sp)
    80000a36:	6105                	addi	sp,sp,32
    80000a38:	8082                	ret
    panic("kfree");
    80000a3a:	00007517          	auipc	a0,0x7
    80000a3e:	62650513          	addi	a0,a0,1574 # 80008060 <digits+0x20>
    80000a42:	00000097          	auipc	ra,0x0
    80000a46:	aea080e7          	jalr	-1302(ra) # 8000052c <panic>

0000000080000a4a <freerange>:
{
    80000a4a:	7179                	addi	sp,sp,-48
    80000a4c:	f406                	sd	ra,40(sp)
    80000a4e:	f022                	sd	s0,32(sp)
    80000a50:	ec26                	sd	s1,24(sp)
    80000a52:	e84a                	sd	s2,16(sp)
    80000a54:	e44e                	sd	s3,8(sp)
    80000a56:	e052                	sd	s4,0(sp)
    80000a58:	1800                	addi	s0,sp,48
  p = (char*)PGROUNDUP((uint64)pa_start);
    80000a5a:	6785                	lui	a5,0x1
    80000a5c:	fff78713          	addi	a4,a5,-1 # fff <_entry-0x7ffff001>
    80000a60:	00e504b3          	add	s1,a0,a4
    80000a64:	777d                	lui	a4,0xfffff
    80000a66:	8cf9                	and	s1,s1,a4
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000a68:	94be                	add	s1,s1,a5
    80000a6a:	0095ee63          	bltu	a1,s1,80000a86 <freerange+0x3c>
    80000a6e:	892e                	mv	s2,a1
    kfree(p);
    80000a70:	7a7d                	lui	s4,0xfffff
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000a72:	6985                	lui	s3,0x1
    kfree(p);
    80000a74:	01448533          	add	a0,s1,s4
    80000a78:	00000097          	auipc	ra,0x0
    80000a7c:	f5c080e7          	jalr	-164(ra) # 800009d4 <kfree>
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000a80:	94ce                	add	s1,s1,s3
    80000a82:	fe9979e3          	bgeu	s2,s1,80000a74 <freerange+0x2a>
}
    80000a86:	70a2                	ld	ra,40(sp)
    80000a88:	7402                	ld	s0,32(sp)
    80000a8a:	64e2                	ld	s1,24(sp)
    80000a8c:	6942                	ld	s2,16(sp)
    80000a8e:	69a2                	ld	s3,8(sp)
    80000a90:	6a02                	ld	s4,0(sp)
    80000a92:	6145                	addi	sp,sp,48
    80000a94:	8082                	ret

0000000080000a96 <kinit>:
{
    80000a96:	1141                	addi	sp,sp,-16
    80000a98:	e406                	sd	ra,8(sp)
    80000a9a:	e022                	sd	s0,0(sp)
    80000a9c:	0800                	addi	s0,sp,16
  initlock(&kmem.lock, "kmem");
    80000a9e:	00007597          	auipc	a1,0x7
    80000aa2:	5ca58593          	addi	a1,a1,1482 # 80008068 <digits+0x28>
    80000aa6:	00010517          	auipc	a0,0x10
    80000aaa:	7da50513          	addi	a0,a0,2010 # 80011280 <kmem>
    80000aae:	00000097          	auipc	ra,0x0
    80000ab2:	084080e7          	jalr	132(ra) # 80000b32 <initlock>
  freerange(end, (void*)PHYSTOP);
    80000ab6:	45c5                	li	a1,17
    80000ab8:	05ee                	slli	a1,a1,0x1b
    80000aba:	00020517          	auipc	a0,0x20
    80000abe:	54650513          	addi	a0,a0,1350 # 80021000 <end>
    80000ac2:	00000097          	auipc	ra,0x0
    80000ac6:	f88080e7          	jalr	-120(ra) # 80000a4a <freerange>
}
    80000aca:	60a2                	ld	ra,8(sp)
    80000acc:	6402                	ld	s0,0(sp)
    80000ace:	0141                	addi	sp,sp,16
    80000ad0:	8082                	ret

0000000080000ad2 <kalloc>:
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
// Returns 0 if the memory cannot be allocated.
void *
kalloc(void)
{
    80000ad2:	1101                	addi	sp,sp,-32
    80000ad4:	ec06                	sd	ra,24(sp)
    80000ad6:	e822                	sd	s0,16(sp)
    80000ad8:	e426                	sd	s1,8(sp)
    80000ada:	1000                	addi	s0,sp,32
  struct run *r;

  acquire(&kmem.lock);
    80000adc:	00010497          	auipc	s1,0x10
    80000ae0:	7a448493          	addi	s1,s1,1956 # 80011280 <kmem>
    80000ae4:	8526                	mv	a0,s1
    80000ae6:	00000097          	auipc	ra,0x0
    80000aea:	0dc080e7          	jalr	220(ra) # 80000bc2 <acquire>
  r = kmem.freelist;
    80000aee:	6c84                	ld	s1,24(s1)
  if(r)
    80000af0:	c885                	beqz	s1,80000b20 <kalloc+0x4e>
    kmem.freelist = r->next;
    80000af2:	609c                	ld	a5,0(s1)
    80000af4:	00010517          	auipc	a0,0x10
    80000af8:	78c50513          	addi	a0,a0,1932 # 80011280 <kmem>
    80000afc:	ed1c                	sd	a5,24(a0)
  release(&kmem.lock);
    80000afe:	00000097          	auipc	ra,0x0
    80000b02:	178080e7          	jalr	376(ra) # 80000c76 <release>

  if(r)
    memset((char*)r, 5, PGSIZE); // fill with junk
    80000b06:	6605                	lui	a2,0x1
    80000b08:	4595                	li	a1,5
    80000b0a:	8526                	mv	a0,s1
    80000b0c:	00000097          	auipc	ra,0x0
    80000b10:	1b2080e7          	jalr	434(ra) # 80000cbe <memset>
  return (void*)r;
}
    80000b14:	8526                	mv	a0,s1
    80000b16:	60e2                	ld	ra,24(sp)
    80000b18:	6442                	ld	s0,16(sp)
    80000b1a:	64a2                	ld	s1,8(sp)
    80000b1c:	6105                	addi	sp,sp,32
    80000b1e:	8082                	ret
  release(&kmem.lock);
    80000b20:	00010517          	auipc	a0,0x10
    80000b24:	76050513          	addi	a0,a0,1888 # 80011280 <kmem>
    80000b28:	00000097          	auipc	ra,0x0
    80000b2c:	14e080e7          	jalr	334(ra) # 80000c76 <release>
  if(r)
    80000b30:	b7d5                	j	80000b14 <kalloc+0x42>

0000000080000b32 <initlock>:
#include "proc.h"
#include "defs.h"

void
initlock(struct spinlock *lk, char *name)
{
    80000b32:	1141                	addi	sp,sp,-16
    80000b34:	e422                	sd	s0,8(sp)
    80000b36:	0800                	addi	s0,sp,16
  lk->name = name;
    80000b38:	e50c                	sd	a1,8(a0)
  lk->locked = 0;
    80000b3a:	00052023          	sw	zero,0(a0)
  lk->cpu = 0;
    80000b3e:	00053823          	sd	zero,16(a0)
}
    80000b42:	6422                	ld	s0,8(sp)
    80000b44:	0141                	addi	sp,sp,16
    80000b46:	8082                	ret

0000000080000b48 <holding>:
// Interrupts must be off.
int
holding(struct spinlock *lk)
{
  int r;
  r = (lk->locked && lk->cpu == mycpu());
    80000b48:	411c                	lw	a5,0(a0)
    80000b4a:	e399                	bnez	a5,80000b50 <holding+0x8>
    80000b4c:	4501                	li	a0,0
  return r;
}
    80000b4e:	8082                	ret
{
    80000b50:	1101                	addi	sp,sp,-32
    80000b52:	ec06                	sd	ra,24(sp)
    80000b54:	e822                	sd	s0,16(sp)
    80000b56:	e426                	sd	s1,8(sp)
    80000b58:	1000                	addi	s0,sp,32
  r = (lk->locked && lk->cpu == mycpu());
    80000b5a:	6904                	ld	s1,16(a0)
    80000b5c:	00001097          	auipc	ra,0x1
    80000b60:	e32080e7          	jalr	-462(ra) # 8000198e <mycpu>
    80000b64:	40a48533          	sub	a0,s1,a0
    80000b68:	00153513          	seqz	a0,a0
}
    80000b6c:	60e2                	ld	ra,24(sp)
    80000b6e:	6442                	ld	s0,16(sp)
    80000b70:	64a2                	ld	s1,8(sp)
    80000b72:	6105                	addi	sp,sp,32
    80000b74:	8082                	ret

0000000080000b76 <push_off>:
// it takes two pop_off()s to undo two push_off()s.  Also, if interrupts
// are initially off, then push_off, pop_off leaves them off.

void
push_off(void)
{
    80000b76:	1101                	addi	sp,sp,-32
    80000b78:	ec06                	sd	ra,24(sp)
    80000b7a:	e822                	sd	s0,16(sp)
    80000b7c:	e426                	sd	s1,8(sp)
    80000b7e:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000b80:	100024f3          	csrr	s1,sstatus
    80000b84:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    80000b88:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000b8a:	10079073          	csrw	sstatus,a5
  int old = intr_get();

  intr_off();
  if(mycpu()->noff == 0)
    80000b8e:	00001097          	auipc	ra,0x1
    80000b92:	e00080e7          	jalr	-512(ra) # 8000198e <mycpu>
    80000b96:	5d3c                	lw	a5,120(a0)
    80000b98:	cf89                	beqz	a5,80000bb2 <push_off+0x3c>
    mycpu()->intena = old;
  mycpu()->noff += 1;
    80000b9a:	00001097          	auipc	ra,0x1
    80000b9e:	df4080e7          	jalr	-524(ra) # 8000198e <mycpu>
    80000ba2:	5d3c                	lw	a5,120(a0)
    80000ba4:	2785                	addiw	a5,a5,1
    80000ba6:	dd3c                	sw	a5,120(a0)
}
    80000ba8:	60e2                	ld	ra,24(sp)
    80000baa:	6442                	ld	s0,16(sp)
    80000bac:	64a2                	ld	s1,8(sp)
    80000bae:	6105                	addi	sp,sp,32
    80000bb0:	8082                	ret
    mycpu()->intena = old;
    80000bb2:	00001097          	auipc	ra,0x1
    80000bb6:	ddc080e7          	jalr	-548(ra) # 8000198e <mycpu>
  return (x & SSTATUS_SIE) != 0;
    80000bba:	8085                	srli	s1,s1,0x1
    80000bbc:	8885                	andi	s1,s1,1
    80000bbe:	dd64                	sw	s1,124(a0)
    80000bc0:	bfe9                	j	80000b9a <push_off+0x24>

0000000080000bc2 <acquire>:
{
    80000bc2:	1101                	addi	sp,sp,-32
    80000bc4:	ec06                	sd	ra,24(sp)
    80000bc6:	e822                	sd	s0,16(sp)
    80000bc8:	e426                	sd	s1,8(sp)
    80000bca:	1000                	addi	s0,sp,32
    80000bcc:	84aa                	mv	s1,a0
  push_off(); // disable interrupts to avoid deadlock.
    80000bce:	00000097          	auipc	ra,0x0
    80000bd2:	fa8080e7          	jalr	-88(ra) # 80000b76 <push_off>
  if(holding(lk))
    80000bd6:	8526                	mv	a0,s1
    80000bd8:	00000097          	auipc	ra,0x0
    80000bdc:	f70080e7          	jalr	-144(ra) # 80000b48 <holding>
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
    80000be0:	4705                	li	a4,1
  if(holding(lk))
    80000be2:	e115                	bnez	a0,80000c06 <acquire+0x44>
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
    80000be4:	87ba                	mv	a5,a4
    80000be6:	0cf4a7af          	amoswap.w.aq	a5,a5,(s1)
    80000bea:	2781                	sext.w	a5,a5
    80000bec:	ffe5                	bnez	a5,80000be4 <acquire+0x22>
  __sync_synchronize();
    80000bee:	0ff0000f          	fence
  lk->cpu = mycpu();
    80000bf2:	00001097          	auipc	ra,0x1
    80000bf6:	d9c080e7          	jalr	-612(ra) # 8000198e <mycpu>
    80000bfa:	e888                	sd	a0,16(s1)
}
    80000bfc:	60e2                	ld	ra,24(sp)
    80000bfe:	6442                	ld	s0,16(sp)
    80000c00:	64a2                	ld	s1,8(sp)
    80000c02:	6105                	addi	sp,sp,32
    80000c04:	8082                	ret
    panic("acquire");
    80000c06:	00007517          	auipc	a0,0x7
    80000c0a:	46a50513          	addi	a0,a0,1130 # 80008070 <digits+0x30>
    80000c0e:	00000097          	auipc	ra,0x0
    80000c12:	91e080e7          	jalr	-1762(ra) # 8000052c <panic>

0000000080000c16 <pop_off>:

void
pop_off(void)
{
    80000c16:	1141                	addi	sp,sp,-16
    80000c18:	e406                	sd	ra,8(sp)
    80000c1a:	e022                	sd	s0,0(sp)
    80000c1c:	0800                	addi	s0,sp,16
  struct cpu *c = mycpu();
    80000c1e:	00001097          	auipc	ra,0x1
    80000c22:	d70080e7          	jalr	-656(ra) # 8000198e <mycpu>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000c26:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80000c2a:	8b89                	andi	a5,a5,2
  if(intr_get())
    80000c2c:	e78d                	bnez	a5,80000c56 <pop_off+0x40>
    panic("pop_off - interruptible");
  if(c->noff < 1)
    80000c2e:	5d3c                	lw	a5,120(a0)
    80000c30:	02f05b63          	blez	a5,80000c66 <pop_off+0x50>
    panic("pop_off");
  c->noff -= 1;
    80000c34:	37fd                	addiw	a5,a5,-1
    80000c36:	0007871b          	sext.w	a4,a5
    80000c3a:	dd3c                	sw	a5,120(a0)
  if(c->noff == 0 && c->intena)
    80000c3c:	eb09                	bnez	a4,80000c4e <pop_off+0x38>
    80000c3e:	5d7c                	lw	a5,124(a0)
    80000c40:	c799                	beqz	a5,80000c4e <pop_off+0x38>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000c42:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80000c46:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000c4a:	10079073          	csrw	sstatus,a5
    intr_on();
}
    80000c4e:	60a2                	ld	ra,8(sp)
    80000c50:	6402                	ld	s0,0(sp)
    80000c52:	0141                	addi	sp,sp,16
    80000c54:	8082                	ret
    panic("pop_off - interruptible");
    80000c56:	00007517          	auipc	a0,0x7
    80000c5a:	42250513          	addi	a0,a0,1058 # 80008078 <digits+0x38>
    80000c5e:	00000097          	auipc	ra,0x0
    80000c62:	8ce080e7          	jalr	-1842(ra) # 8000052c <panic>
    panic("pop_off");
    80000c66:	00007517          	auipc	a0,0x7
    80000c6a:	42a50513          	addi	a0,a0,1066 # 80008090 <digits+0x50>
    80000c6e:	00000097          	auipc	ra,0x0
    80000c72:	8be080e7          	jalr	-1858(ra) # 8000052c <panic>

0000000080000c76 <release>:
{
    80000c76:	1101                	addi	sp,sp,-32
    80000c78:	ec06                	sd	ra,24(sp)
    80000c7a:	e822                	sd	s0,16(sp)
    80000c7c:	e426                	sd	s1,8(sp)
    80000c7e:	1000                	addi	s0,sp,32
    80000c80:	84aa                	mv	s1,a0
  if(!holding(lk))
    80000c82:	00000097          	auipc	ra,0x0
    80000c86:	ec6080e7          	jalr	-314(ra) # 80000b48 <holding>
    80000c8a:	c115                	beqz	a0,80000cae <release+0x38>
  lk->cpu = 0;
    80000c8c:	0004b823          	sd	zero,16(s1)
  __sync_synchronize();
    80000c90:	0ff0000f          	fence
  __sync_lock_release(&lk->locked);
    80000c94:	0f50000f          	fence	iorw,ow
    80000c98:	0804a02f          	amoswap.w	zero,zero,(s1)
  pop_off();
    80000c9c:	00000097          	auipc	ra,0x0
    80000ca0:	f7a080e7          	jalr	-134(ra) # 80000c16 <pop_off>
}
    80000ca4:	60e2                	ld	ra,24(sp)
    80000ca6:	6442                	ld	s0,16(sp)
    80000ca8:	64a2                	ld	s1,8(sp)
    80000caa:	6105                	addi	sp,sp,32
    80000cac:	8082                	ret
    panic("release");
    80000cae:	00007517          	auipc	a0,0x7
    80000cb2:	3ea50513          	addi	a0,a0,1002 # 80008098 <digits+0x58>
    80000cb6:	00000097          	auipc	ra,0x0
    80000cba:	876080e7          	jalr	-1930(ra) # 8000052c <panic>

0000000080000cbe <memset>:
#include "types.h"

void*
memset(void *dst, int c, uint n)
{
    80000cbe:	1141                	addi	sp,sp,-16
    80000cc0:	e422                	sd	s0,8(sp)
    80000cc2:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
    80000cc4:	ca19                	beqz	a2,80000cda <memset+0x1c>
    80000cc6:	87aa                	mv	a5,a0
    80000cc8:	1602                	slli	a2,a2,0x20
    80000cca:	9201                	srli	a2,a2,0x20
    80000ccc:	00a60733          	add	a4,a2,a0
    cdst[i] = c;
    80000cd0:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
    80000cd4:	0785                	addi	a5,a5,1
    80000cd6:	fee79de3          	bne	a5,a4,80000cd0 <memset+0x12>
  }
  return dst;
}
    80000cda:	6422                	ld	s0,8(sp)
    80000cdc:	0141                	addi	sp,sp,16
    80000cde:	8082                	ret

0000000080000ce0 <memcmp>:

int
memcmp(const void *v1, const void *v2, uint n)
{
    80000ce0:	1141                	addi	sp,sp,-16
    80000ce2:	e422                	sd	s0,8(sp)
    80000ce4:	0800                	addi	s0,sp,16
  const uchar *s1, *s2;

  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    80000ce6:	ca05                	beqz	a2,80000d16 <memcmp+0x36>
    80000ce8:	fff6069b          	addiw	a3,a2,-1 # fff <_entry-0x7ffff001>
    80000cec:	1682                	slli	a3,a3,0x20
    80000cee:	9281                	srli	a3,a3,0x20
    80000cf0:	0685                	addi	a3,a3,1
    80000cf2:	96aa                	add	a3,a3,a0
    if(*s1 != *s2)
    80000cf4:	00054783          	lbu	a5,0(a0)
    80000cf8:	0005c703          	lbu	a4,0(a1)
    80000cfc:	00e79863          	bne	a5,a4,80000d0c <memcmp+0x2c>
      return *s1 - *s2;
    s1++, s2++;
    80000d00:	0505                	addi	a0,a0,1
    80000d02:	0585                	addi	a1,a1,1
  while(n-- > 0){
    80000d04:	fed518e3          	bne	a0,a3,80000cf4 <memcmp+0x14>
  }

  return 0;
    80000d08:	4501                	li	a0,0
    80000d0a:	a019                	j	80000d10 <memcmp+0x30>
      return *s1 - *s2;
    80000d0c:	40e7853b          	subw	a0,a5,a4
}
    80000d10:	6422                	ld	s0,8(sp)
    80000d12:	0141                	addi	sp,sp,16
    80000d14:	8082                	ret
  return 0;
    80000d16:	4501                	li	a0,0
    80000d18:	bfe5                	j	80000d10 <memcmp+0x30>

0000000080000d1a <memmove>:

void*
memmove(void *dst, const void *src, uint n)
{
    80000d1a:	1141                	addi	sp,sp,-16
    80000d1c:	e422                	sd	s0,8(sp)
    80000d1e:	0800                	addi	s0,sp,16
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
    80000d20:	02a5e563          	bltu	a1,a0,80000d4a <memmove+0x30>
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else
    while(n-- > 0)
    80000d24:	fff6069b          	addiw	a3,a2,-1
    80000d28:	ce11                	beqz	a2,80000d44 <memmove+0x2a>
    80000d2a:	1682                	slli	a3,a3,0x20
    80000d2c:	9281                	srli	a3,a3,0x20
    80000d2e:	0685                	addi	a3,a3,1
    80000d30:	96ae                	add	a3,a3,a1
    80000d32:	87aa                	mv	a5,a0
      *d++ = *s++;
    80000d34:	0585                	addi	a1,a1,1
    80000d36:	0785                	addi	a5,a5,1
    80000d38:	fff5c703          	lbu	a4,-1(a1)
    80000d3c:	fee78fa3          	sb	a4,-1(a5)
    while(n-- > 0)
    80000d40:	fed59ae3          	bne	a1,a3,80000d34 <memmove+0x1a>

  return dst;
}
    80000d44:	6422                	ld	s0,8(sp)
    80000d46:	0141                	addi	sp,sp,16
    80000d48:	8082                	ret
  if(s < d && s + n > d){
    80000d4a:	02061713          	slli	a4,a2,0x20
    80000d4e:	9301                	srli	a4,a4,0x20
    80000d50:	00e587b3          	add	a5,a1,a4
    80000d54:	fcf578e3          	bgeu	a0,a5,80000d24 <memmove+0xa>
    d += n;
    80000d58:	972a                	add	a4,a4,a0
    while(n-- > 0)
    80000d5a:	fff6069b          	addiw	a3,a2,-1
    80000d5e:	d27d                	beqz	a2,80000d44 <memmove+0x2a>
    80000d60:	02069613          	slli	a2,a3,0x20
    80000d64:	9201                	srli	a2,a2,0x20
    80000d66:	fff64613          	not	a2,a2
    80000d6a:	963e                	add	a2,a2,a5
      *--d = *--s;
    80000d6c:	17fd                	addi	a5,a5,-1
    80000d6e:	177d                	addi	a4,a4,-1 # ffffffffffffefff <end+0xffffffff7ffddfff>
    80000d70:	0007c683          	lbu	a3,0(a5)
    80000d74:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
    80000d78:	fef61ae3          	bne	a2,a5,80000d6c <memmove+0x52>
    80000d7c:	b7e1                	j	80000d44 <memmove+0x2a>

0000000080000d7e <memcpy>:

// memcpy exists to placate GCC.  Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
    80000d7e:	1141                	addi	sp,sp,-16
    80000d80:	e406                	sd	ra,8(sp)
    80000d82:	e022                	sd	s0,0(sp)
    80000d84:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
    80000d86:	00000097          	auipc	ra,0x0
    80000d8a:	f94080e7          	jalr	-108(ra) # 80000d1a <memmove>
}
    80000d8e:	60a2                	ld	ra,8(sp)
    80000d90:	6402                	ld	s0,0(sp)
    80000d92:	0141                	addi	sp,sp,16
    80000d94:	8082                	ret

0000000080000d96 <strncmp>:

int
strncmp(const char *p, const char *q, uint n)
{
    80000d96:	1141                	addi	sp,sp,-16
    80000d98:	e422                	sd	s0,8(sp)
    80000d9a:	0800                	addi	s0,sp,16
  while(n > 0 && *p && *p == *q)
    80000d9c:	ce11                	beqz	a2,80000db8 <strncmp+0x22>
    80000d9e:	00054783          	lbu	a5,0(a0)
    80000da2:	cf89                	beqz	a5,80000dbc <strncmp+0x26>
    80000da4:	0005c703          	lbu	a4,0(a1)
    80000da8:	00f71a63          	bne	a4,a5,80000dbc <strncmp+0x26>
    n--, p++, q++;
    80000dac:	367d                	addiw	a2,a2,-1
    80000dae:	0505                	addi	a0,a0,1
    80000db0:	0585                	addi	a1,a1,1
  while(n > 0 && *p && *p == *q)
    80000db2:	f675                	bnez	a2,80000d9e <strncmp+0x8>
  if(n == 0)
    return 0;
    80000db4:	4501                	li	a0,0
    80000db6:	a809                	j	80000dc8 <strncmp+0x32>
    80000db8:	4501                	li	a0,0
    80000dba:	a039                	j	80000dc8 <strncmp+0x32>
  if(n == 0)
    80000dbc:	ca09                	beqz	a2,80000dce <strncmp+0x38>
  return (uchar)*p - (uchar)*q;
    80000dbe:	00054503          	lbu	a0,0(a0)
    80000dc2:	0005c783          	lbu	a5,0(a1)
    80000dc6:	9d1d                	subw	a0,a0,a5
}
    80000dc8:	6422                	ld	s0,8(sp)
    80000dca:	0141                	addi	sp,sp,16
    80000dcc:	8082                	ret
    return 0;
    80000dce:	4501                	li	a0,0
    80000dd0:	bfe5                	j	80000dc8 <strncmp+0x32>

0000000080000dd2 <strncpy>:

char*
strncpy(char *s, const char *t, int n)
{
    80000dd2:	1141                	addi	sp,sp,-16
    80000dd4:	e422                	sd	s0,8(sp)
    80000dd6:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
    80000dd8:	872a                	mv	a4,a0
    80000dda:	8832                	mv	a6,a2
    80000ddc:	367d                	addiw	a2,a2,-1
    80000dde:	01005963          	blez	a6,80000df0 <strncpy+0x1e>
    80000de2:	0705                	addi	a4,a4,1
    80000de4:	0005c783          	lbu	a5,0(a1)
    80000de8:	fef70fa3          	sb	a5,-1(a4)
    80000dec:	0585                	addi	a1,a1,1
    80000dee:	f7f5                	bnez	a5,80000dda <strncpy+0x8>
    ;
  while(n-- > 0)
    80000df0:	86ba                	mv	a3,a4
    80000df2:	00c05c63          	blez	a2,80000e0a <strncpy+0x38>
    *s++ = 0;
    80000df6:	0685                	addi	a3,a3,1
    80000df8:	fe068fa3          	sb	zero,-1(a3)
  while(n-- > 0)
    80000dfc:	40d707bb          	subw	a5,a4,a3
    80000e00:	37fd                	addiw	a5,a5,-1
    80000e02:	010787bb          	addw	a5,a5,a6
    80000e06:	fef048e3          	bgtz	a5,80000df6 <strncpy+0x24>
  return os;
}
    80000e0a:	6422                	ld	s0,8(sp)
    80000e0c:	0141                	addi	sp,sp,16
    80000e0e:	8082                	ret

0000000080000e10 <safestrcpy>:

// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
    80000e10:	1141                	addi	sp,sp,-16
    80000e12:	e422                	sd	s0,8(sp)
    80000e14:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  if(n <= 0)
    80000e16:	02c05363          	blez	a2,80000e3c <safestrcpy+0x2c>
    80000e1a:	fff6069b          	addiw	a3,a2,-1
    80000e1e:	1682                	slli	a3,a3,0x20
    80000e20:	9281                	srli	a3,a3,0x20
    80000e22:	96ae                	add	a3,a3,a1
    80000e24:	87aa                	mv	a5,a0
    return os;
  while(--n > 0 && (*s++ = *t++) != 0)
    80000e26:	00d58963          	beq	a1,a3,80000e38 <safestrcpy+0x28>
    80000e2a:	0585                	addi	a1,a1,1
    80000e2c:	0785                	addi	a5,a5,1
    80000e2e:	fff5c703          	lbu	a4,-1(a1)
    80000e32:	fee78fa3          	sb	a4,-1(a5)
    80000e36:	fb65                	bnez	a4,80000e26 <safestrcpy+0x16>
    ;
  *s = 0;
    80000e38:	00078023          	sb	zero,0(a5)
  return os;
}
    80000e3c:	6422                	ld	s0,8(sp)
    80000e3e:	0141                	addi	sp,sp,16
    80000e40:	8082                	ret

0000000080000e42 <strlen>:

int
strlen(const char *s)
{
    80000e42:	1141                	addi	sp,sp,-16
    80000e44:	e422                	sd	s0,8(sp)
    80000e46:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
    80000e48:	00054783          	lbu	a5,0(a0)
    80000e4c:	cf91                	beqz	a5,80000e68 <strlen+0x26>
    80000e4e:	0505                	addi	a0,a0,1
    80000e50:	87aa                	mv	a5,a0
    80000e52:	4685                	li	a3,1
    80000e54:	9e89                	subw	a3,a3,a0
    80000e56:	00f6853b          	addw	a0,a3,a5
    80000e5a:	0785                	addi	a5,a5,1
    80000e5c:	fff7c703          	lbu	a4,-1(a5)
    80000e60:	fb7d                	bnez	a4,80000e56 <strlen+0x14>
    ;
  return n;
}
    80000e62:	6422                	ld	s0,8(sp)
    80000e64:	0141                	addi	sp,sp,16
    80000e66:	8082                	ret
  for(n = 0; s[n]; n++)
    80000e68:	4501                	li	a0,0
    80000e6a:	bfe5                	j	80000e62 <strlen+0x20>

0000000080000e6c <main>:
volatile static int started = 0;

// start() jumps here in supervisor mode on all CPUs.
void
main()
{
    80000e6c:	1141                	addi	sp,sp,-16
    80000e6e:	e406                	sd	ra,8(sp)
    80000e70:	e022                	sd	s0,0(sp)
    80000e72:	0800                	addi	s0,sp,16
  if(cpuid() == 0){
    80000e74:	00001097          	auipc	ra,0x1
    80000e78:	b0a080e7          	jalr	-1270(ra) # 8000197e <cpuid>
    virtio_disk_init(); // emulated hard disk
    userinit();      // first user process
    __sync_synchronize();
    started = 1;
  } else {
    while(started == 0)
    80000e7c:	00008717          	auipc	a4,0x8
    80000e80:	19c70713          	addi	a4,a4,412 # 80009018 <started>
  if(cpuid() == 0){
    80000e84:	c139                	beqz	a0,80000eca <main+0x5e>
    while(started == 0)
    80000e86:	431c                	lw	a5,0(a4)
    80000e88:	2781                	sext.w	a5,a5
    80000e8a:	dff5                	beqz	a5,80000e86 <main+0x1a>
      ;
    __sync_synchronize();
    80000e8c:	0ff0000f          	fence
    printf("hart %d starting\n", cpuid());
    80000e90:	00001097          	auipc	ra,0x1
    80000e94:	aee080e7          	jalr	-1298(ra) # 8000197e <cpuid>
    80000e98:	85aa                	mv	a1,a0
    80000e9a:	00007517          	auipc	a0,0x7
    80000e9e:	21e50513          	addi	a0,a0,542 # 800080b8 <digits+0x78>
    80000ea2:	fffff097          	auipc	ra,0xfffff
    80000ea6:	6d4080e7          	jalr	1748(ra) # 80000576 <printf>
    kvminithart();    // turn on paging
    80000eaa:	00000097          	auipc	ra,0x0
    80000eae:	0d8080e7          	jalr	216(ra) # 80000f82 <kvminithart>
    trapinithart();   // install kernel trap vector
    80000eb2:	00001097          	auipc	ra,0x1
    80000eb6:	758080e7          	jalr	1880(ra) # 8000260a <trapinithart>
    plicinithart();   // ask PLIC for device interrupts
    80000eba:	00005097          	auipc	ra,0x5
    80000ebe:	766080e7          	jalr	1894(ra) # 80006620 <plicinithart>
  }

  scheduler();        
    80000ec2:	00001097          	auipc	ra,0x1
    80000ec6:	020080e7          	jalr	32(ra) # 80001ee2 <scheduler>
    consoleinit();
    80000eca:	fffff097          	auipc	ra,0xfffff
    80000ece:	572080e7          	jalr	1394(ra) # 8000043c <consoleinit>
    printfinit();
    80000ed2:	00000097          	auipc	ra,0x0
    80000ed6:	884080e7          	jalr	-1916(ra) # 80000756 <printfinit>
    printf("\n");
    80000eda:	00007517          	auipc	a0,0x7
    80000ede:	1ee50513          	addi	a0,a0,494 # 800080c8 <digits+0x88>
    80000ee2:	fffff097          	auipc	ra,0xfffff
    80000ee6:	694080e7          	jalr	1684(ra) # 80000576 <printf>
    printf("xv6 kernel is booting\n");
    80000eea:	00007517          	auipc	a0,0x7
    80000eee:	1b650513          	addi	a0,a0,438 # 800080a0 <digits+0x60>
    80000ef2:	fffff097          	auipc	ra,0xfffff
    80000ef6:	684080e7          	jalr	1668(ra) # 80000576 <printf>
    printf("\n");
    80000efa:	00007517          	auipc	a0,0x7
    80000efe:	1ce50513          	addi	a0,a0,462 # 800080c8 <digits+0x88>
    80000f02:	fffff097          	auipc	ra,0xfffff
    80000f06:	674080e7          	jalr	1652(ra) # 80000576 <printf>
    kinit();         // physical page allocator
    80000f0a:	00000097          	auipc	ra,0x0
    80000f0e:	b8c080e7          	jalr	-1140(ra) # 80000a96 <kinit>
    kvminit();       // create kernel page table
    80000f12:	00000097          	auipc	ra,0x0
    80000f16:	310080e7          	jalr	784(ra) # 80001222 <kvminit>
    kvminithart();   // turn on paging
    80000f1a:	00000097          	auipc	ra,0x0
    80000f1e:	068080e7          	jalr	104(ra) # 80000f82 <kvminithart>
    procinit();      // process table
    80000f22:	00001097          	auipc	ra,0x1
    80000f26:	9c4080e7          	jalr	-1596(ra) # 800018e6 <procinit>
    trapinit();      // trap vectors
    80000f2a:	00001097          	auipc	ra,0x1
    80000f2e:	6b8080e7          	jalr	1720(ra) # 800025e2 <trapinit>
    trapinithart();  // install kernel trap vector
    80000f32:	00001097          	auipc	ra,0x1
    80000f36:	6d8080e7          	jalr	1752(ra) # 8000260a <trapinithart>
    plicinit();      // set up interrupt controller
    80000f3a:	00005097          	auipc	ra,0x5
    80000f3e:	6d0080e7          	jalr	1744(ra) # 8000660a <plicinit>
    plicinithart();  // ask PLIC for device interrupts
    80000f42:	00005097          	auipc	ra,0x5
    80000f46:	6de080e7          	jalr	1758(ra) # 80006620 <plicinithart>
    binit();         // buffer cache
    80000f4a:	00002097          	auipc	ra,0x2
    80000f4e:	e02080e7          	jalr	-510(ra) # 80002d4c <binit>
    iinit();         // inode cache
    80000f52:	00002097          	auipc	ra,0x2
    80000f56:	558080e7          	jalr	1368(ra) # 800034aa <iinit>
    fileinit();      // file table
    80000f5a:	00004097          	auipc	ra,0x4
    80000f5e:	d2a080e7          	jalr	-726(ra) # 80004c84 <fileinit>
    virtio_disk_init(); // emulated hard disk
    80000f62:	00005097          	auipc	ra,0x5
    80000f66:	7de080e7          	jalr	2014(ra) # 80006740 <virtio_disk_init>
    userinit();      // first user process
    80000f6a:	00001097          	auipc	ra,0x1
    80000f6e:	d0a080e7          	jalr	-758(ra) # 80001c74 <userinit>
    __sync_synchronize();
    80000f72:	0ff0000f          	fence
    started = 1;
    80000f76:	4785                	li	a5,1
    80000f78:	00008717          	auipc	a4,0x8
    80000f7c:	0af72023          	sw	a5,160(a4) # 80009018 <started>
    80000f80:	b789                	j	80000ec2 <main+0x56>

0000000080000f82 <kvminithart>:

// Switch h/w page table register to the kernel's page table,
// and enable paging.
void
kvminithart()
{
    80000f82:	1141                	addi	sp,sp,-16
    80000f84:	e422                	sd	s0,8(sp)
    80000f86:	0800                	addi	s0,sp,16
  w_satp(MAKE_SATP(kernel_pagetable));
    80000f88:	00008797          	auipc	a5,0x8
    80000f8c:	0987b783          	ld	a5,152(a5) # 80009020 <kernel_pagetable>
    80000f90:	83b1                	srli	a5,a5,0xc
    80000f92:	577d                	li	a4,-1
    80000f94:	177e                	slli	a4,a4,0x3f
    80000f96:	8fd9                	or	a5,a5,a4
  asm volatile("csrw satp, %0" : : "r" (x));
    80000f98:	18079073          	csrw	satp,a5
// flush the TLB.
static inline void
sfence_vma()
{
  // the zero, zero means flush all TLB entries.
  asm volatile("sfence.vma zero, zero");
    80000f9c:	12000073          	sfence.vma
  sfence_vma();
}
    80000fa0:	6422                	ld	s0,8(sp)
    80000fa2:	0141                	addi	sp,sp,16
    80000fa4:	8082                	ret

0000000080000fa6 <walk>:
//   21..29 -- 9 bits of level-1 index.
//   12..20 -- 9 bits of level-0 index.
//    0..11 -- 12 bits of byte offset within the page.
pte_t *
walk(pagetable_t pagetable, uint64 va, int alloc)
{
    80000fa6:	7139                	addi	sp,sp,-64
    80000fa8:	fc06                	sd	ra,56(sp)
    80000faa:	f822                	sd	s0,48(sp)
    80000fac:	f426                	sd	s1,40(sp)
    80000fae:	f04a                	sd	s2,32(sp)
    80000fb0:	ec4e                	sd	s3,24(sp)
    80000fb2:	e852                	sd	s4,16(sp)
    80000fb4:	e456                	sd	s5,8(sp)
    80000fb6:	e05a                	sd	s6,0(sp)
    80000fb8:	0080                	addi	s0,sp,64
    80000fba:	84aa                	mv	s1,a0
    80000fbc:	89ae                	mv	s3,a1
    80000fbe:	8ab2                	mv	s5,a2
  if(va >= MAXVA)
    80000fc0:	57fd                	li	a5,-1
    80000fc2:	83e9                	srli	a5,a5,0x1a
    80000fc4:	4a79                	li	s4,30
    panic("walk");

  for(int level = 2; level > 0; level--) {
    80000fc6:	4b31                	li	s6,12
  if(va >= MAXVA)
    80000fc8:	04b7f263          	bgeu	a5,a1,8000100c <walk+0x66>
    panic("walk");
    80000fcc:	00007517          	auipc	a0,0x7
    80000fd0:	10450513          	addi	a0,a0,260 # 800080d0 <digits+0x90>
    80000fd4:	fffff097          	auipc	ra,0xfffff
    80000fd8:	558080e7          	jalr	1368(ra) # 8000052c <panic>
    pte_t *pte = &pagetable[PX(level, va)];
    if(*pte & PTE_V) {
      pagetable = (pagetable_t)PTE2PA(*pte);
    } else {
      if(!alloc || (pagetable = (pde_t*)kalloc()) == 0)
    80000fdc:	060a8663          	beqz	s5,80001048 <walk+0xa2>
    80000fe0:	00000097          	auipc	ra,0x0
    80000fe4:	af2080e7          	jalr	-1294(ra) # 80000ad2 <kalloc>
    80000fe8:	84aa                	mv	s1,a0
    80000fea:	c529                	beqz	a0,80001034 <walk+0x8e>
        return 0;
      memset(pagetable, 0, PGSIZE);
    80000fec:	6605                	lui	a2,0x1
    80000fee:	4581                	li	a1,0
    80000ff0:	00000097          	auipc	ra,0x0
    80000ff4:	cce080e7          	jalr	-818(ra) # 80000cbe <memset>
      *pte = PA2PTE(pagetable) | PTE_V;
    80000ff8:	00c4d793          	srli	a5,s1,0xc
    80000ffc:	07aa                	slli	a5,a5,0xa
    80000ffe:	0017e793          	ori	a5,a5,1
    80001002:	00f93023          	sd	a5,0(s2)
  for(int level = 2; level > 0; level--) {
    80001006:	3a5d                	addiw	s4,s4,-9 # ffffffffffffeff7 <end+0xffffffff7ffddff7>
    80001008:	036a0063          	beq	s4,s6,80001028 <walk+0x82>
    pte_t *pte = &pagetable[PX(level, va)];
    8000100c:	0149d933          	srl	s2,s3,s4
    80001010:	1ff97913          	andi	s2,s2,511
    80001014:	090e                	slli	s2,s2,0x3
    80001016:	9926                	add	s2,s2,s1
    if(*pte & PTE_V) {
    80001018:	00093483          	ld	s1,0(s2)
    8000101c:	0014f793          	andi	a5,s1,1
    80001020:	dfd5                	beqz	a5,80000fdc <walk+0x36>
      pagetable = (pagetable_t)PTE2PA(*pte);
    80001022:	80a9                	srli	s1,s1,0xa
    80001024:	04b2                	slli	s1,s1,0xc
    80001026:	b7c5                	j	80001006 <walk+0x60>
    }
  }
  return &pagetable[PX(0, va)];
    80001028:	00c9d513          	srli	a0,s3,0xc
    8000102c:	1ff57513          	andi	a0,a0,511
    80001030:	050e                	slli	a0,a0,0x3
    80001032:	9526                	add	a0,a0,s1
}
    80001034:	70e2                	ld	ra,56(sp)
    80001036:	7442                	ld	s0,48(sp)
    80001038:	74a2                	ld	s1,40(sp)
    8000103a:	7902                	ld	s2,32(sp)
    8000103c:	69e2                	ld	s3,24(sp)
    8000103e:	6a42                	ld	s4,16(sp)
    80001040:	6aa2                	ld	s5,8(sp)
    80001042:	6b02                	ld	s6,0(sp)
    80001044:	6121                	addi	sp,sp,64
    80001046:	8082                	ret
        return 0;
    80001048:	4501                	li	a0,0
    8000104a:	b7ed                	j	80001034 <walk+0x8e>

000000008000104c <walkaddr>:
walkaddr(pagetable_t pagetable, uint64 va)
{
  pte_t *pte;
  uint64 pa;

  if(va >= MAXVA)
    8000104c:	57fd                	li	a5,-1
    8000104e:	83e9                	srli	a5,a5,0x1a
    80001050:	00b7f463          	bgeu	a5,a1,80001058 <walkaddr+0xc>
    return 0;
    80001054:	4501                	li	a0,0
    return 0;
  if((*pte & PTE_U) == 0)
    return 0;
  pa = PTE2PA(*pte);
  return pa;
}
    80001056:	8082                	ret
{
    80001058:	1141                	addi	sp,sp,-16
    8000105a:	e406                	sd	ra,8(sp)
    8000105c:	e022                	sd	s0,0(sp)
    8000105e:	0800                	addi	s0,sp,16
  pte = walk(pagetable, va, 0);
    80001060:	4601                	li	a2,0
    80001062:	00000097          	auipc	ra,0x0
    80001066:	f44080e7          	jalr	-188(ra) # 80000fa6 <walk>
  if(pte == 0)
    8000106a:	c105                	beqz	a0,8000108a <walkaddr+0x3e>
  if((*pte & PTE_V) == 0)
    8000106c:	611c                	ld	a5,0(a0)
  if((*pte & PTE_U) == 0)
    8000106e:	0117f693          	andi	a3,a5,17
    80001072:	4745                	li	a4,17
    return 0;
    80001074:	4501                	li	a0,0
  if((*pte & PTE_U) == 0)
    80001076:	00e68663          	beq	a3,a4,80001082 <walkaddr+0x36>
}
    8000107a:	60a2                	ld	ra,8(sp)
    8000107c:	6402                	ld	s0,0(sp)
    8000107e:	0141                	addi	sp,sp,16
    80001080:	8082                	ret
  pa = PTE2PA(*pte);
    80001082:	83a9                	srli	a5,a5,0xa
    80001084:	00c79513          	slli	a0,a5,0xc
  return pa;
    80001088:	bfcd                	j	8000107a <walkaddr+0x2e>
    return 0;
    8000108a:	4501                	li	a0,0
    8000108c:	b7fd                	j	8000107a <walkaddr+0x2e>

000000008000108e <mappages>:
// physical addresses starting at pa. va and size might not
// be page-aligned. Returns 0 on success, -1 if walk() couldn't
// allocate a needed page-table page.
int
mappages(pagetable_t pagetable, uint64 va, uint64 size, uint64 pa, int perm)
{
    8000108e:	715d                	addi	sp,sp,-80
    80001090:	e486                	sd	ra,72(sp)
    80001092:	e0a2                	sd	s0,64(sp)
    80001094:	fc26                	sd	s1,56(sp)
    80001096:	f84a                	sd	s2,48(sp)
    80001098:	f44e                	sd	s3,40(sp)
    8000109a:	f052                	sd	s4,32(sp)
    8000109c:	ec56                	sd	s5,24(sp)
    8000109e:	e85a                	sd	s6,16(sp)
    800010a0:	e45e                	sd	s7,8(sp)
    800010a2:	0880                	addi	s0,sp,80
    800010a4:	8aaa                	mv	s5,a0
    800010a6:	8b3a                	mv	s6,a4
  uint64 a, last;
  pte_t *pte;

  a = PGROUNDDOWN(va);
    800010a8:	777d                	lui	a4,0xfffff
    800010aa:	00e5f7b3          	and	a5,a1,a4
  last = PGROUNDDOWN(va + size - 1);
    800010ae:	fff60993          	addi	s3,a2,-1 # fff <_entry-0x7ffff001>
    800010b2:	99ae                	add	s3,s3,a1
    800010b4:	00e9f9b3          	and	s3,s3,a4
  a = PGROUNDDOWN(va);
    800010b8:	893e                	mv	s2,a5
    800010ba:	40f68a33          	sub	s4,a3,a5
    if(*pte & PTE_V)
      panic("remap");
    *pte = PA2PTE(pa) | perm | PTE_V;
    if(a == last)
      break;
    a += PGSIZE;
    800010be:	6b85                	lui	s7,0x1
    800010c0:	012a04b3          	add	s1,s4,s2
    if((pte = walk(pagetable, a, 1)) == 0)
    800010c4:	4605                	li	a2,1
    800010c6:	85ca                	mv	a1,s2
    800010c8:	8556                	mv	a0,s5
    800010ca:	00000097          	auipc	ra,0x0
    800010ce:	edc080e7          	jalr	-292(ra) # 80000fa6 <walk>
    800010d2:	c51d                	beqz	a0,80001100 <mappages+0x72>
    if(*pte & PTE_V)
    800010d4:	611c                	ld	a5,0(a0)
    800010d6:	8b85                	andi	a5,a5,1
    800010d8:	ef81                	bnez	a5,800010f0 <mappages+0x62>
    *pte = PA2PTE(pa) | perm | PTE_V;
    800010da:	80b1                	srli	s1,s1,0xc
    800010dc:	04aa                	slli	s1,s1,0xa
    800010de:	0164e4b3          	or	s1,s1,s6
    800010e2:	0014e493          	ori	s1,s1,1
    800010e6:	e104                	sd	s1,0(a0)
    if(a == last)
    800010e8:	03390863          	beq	s2,s3,80001118 <mappages+0x8a>
    a += PGSIZE;
    800010ec:	995e                	add	s2,s2,s7
    if((pte = walk(pagetable, a, 1)) == 0)
    800010ee:	bfc9                	j	800010c0 <mappages+0x32>
      panic("remap");
    800010f0:	00007517          	auipc	a0,0x7
    800010f4:	fe850513          	addi	a0,a0,-24 # 800080d8 <digits+0x98>
    800010f8:	fffff097          	auipc	ra,0xfffff
    800010fc:	434080e7          	jalr	1076(ra) # 8000052c <panic>
      return -1;
    80001100:	557d                	li	a0,-1
    pa += PGSIZE;
  }
  return 0;
}
    80001102:	60a6                	ld	ra,72(sp)
    80001104:	6406                	ld	s0,64(sp)
    80001106:	74e2                	ld	s1,56(sp)
    80001108:	7942                	ld	s2,48(sp)
    8000110a:	79a2                	ld	s3,40(sp)
    8000110c:	7a02                	ld	s4,32(sp)
    8000110e:	6ae2                	ld	s5,24(sp)
    80001110:	6b42                	ld	s6,16(sp)
    80001112:	6ba2                	ld	s7,8(sp)
    80001114:	6161                	addi	sp,sp,80
    80001116:	8082                	ret
  return 0;
    80001118:	4501                	li	a0,0
    8000111a:	b7e5                	j	80001102 <mappages+0x74>

000000008000111c <kvmmap>:
{
    8000111c:	1141                	addi	sp,sp,-16
    8000111e:	e406                	sd	ra,8(sp)
    80001120:	e022                	sd	s0,0(sp)
    80001122:	0800                	addi	s0,sp,16
    80001124:	87b6                	mv	a5,a3
  if(mappages(kpgtbl, va, sz, pa, perm) != 0)
    80001126:	86b2                	mv	a3,a2
    80001128:	863e                	mv	a2,a5
    8000112a:	00000097          	auipc	ra,0x0
    8000112e:	f64080e7          	jalr	-156(ra) # 8000108e <mappages>
    80001132:	e509                	bnez	a0,8000113c <kvmmap+0x20>
}
    80001134:	60a2                	ld	ra,8(sp)
    80001136:	6402                	ld	s0,0(sp)
    80001138:	0141                	addi	sp,sp,16
    8000113a:	8082                	ret
    panic("kvmmap");
    8000113c:	00007517          	auipc	a0,0x7
    80001140:	fa450513          	addi	a0,a0,-92 # 800080e0 <digits+0xa0>
    80001144:	fffff097          	auipc	ra,0xfffff
    80001148:	3e8080e7          	jalr	1000(ra) # 8000052c <panic>

000000008000114c <kvmmake>:
{
    8000114c:	1101                	addi	sp,sp,-32
    8000114e:	ec06                	sd	ra,24(sp)
    80001150:	e822                	sd	s0,16(sp)
    80001152:	e426                	sd	s1,8(sp)
    80001154:	e04a                	sd	s2,0(sp)
    80001156:	1000                	addi	s0,sp,32
  kpgtbl = (pagetable_t) kalloc();
    80001158:	00000097          	auipc	ra,0x0
    8000115c:	97a080e7          	jalr	-1670(ra) # 80000ad2 <kalloc>
    80001160:	84aa                	mv	s1,a0
  memset(kpgtbl, 0, PGSIZE);
    80001162:	6605                	lui	a2,0x1
    80001164:	4581                	li	a1,0
    80001166:	00000097          	auipc	ra,0x0
    8000116a:	b58080e7          	jalr	-1192(ra) # 80000cbe <memset>
  kvmmap(kpgtbl, UART0, UART0, PGSIZE, PTE_R | PTE_W);
    8000116e:	4719                	li	a4,6
    80001170:	6685                	lui	a3,0x1
    80001172:	10000637          	lui	a2,0x10000
    80001176:	100005b7          	lui	a1,0x10000
    8000117a:	8526                	mv	a0,s1
    8000117c:	00000097          	auipc	ra,0x0
    80001180:	fa0080e7          	jalr	-96(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, VIRTIO0, VIRTIO0, PGSIZE, PTE_R | PTE_W);
    80001184:	4719                	li	a4,6
    80001186:	6685                	lui	a3,0x1
    80001188:	10001637          	lui	a2,0x10001
    8000118c:	100015b7          	lui	a1,0x10001
    80001190:	8526                	mv	a0,s1
    80001192:	00000097          	auipc	ra,0x0
    80001196:	f8a080e7          	jalr	-118(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, PLIC, PLIC, 0x400000, PTE_R | PTE_W);
    8000119a:	4719                	li	a4,6
    8000119c:	004006b7          	lui	a3,0x400
    800011a0:	0c000637          	lui	a2,0xc000
    800011a4:	0c0005b7          	lui	a1,0xc000
    800011a8:	8526                	mv	a0,s1
    800011aa:	00000097          	auipc	ra,0x0
    800011ae:	f72080e7          	jalr	-142(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
    800011b2:	00007917          	auipc	s2,0x7
    800011b6:	e4e90913          	addi	s2,s2,-434 # 80008000 <etext>
    800011ba:	4729                	li	a4,10
    800011bc:	80007697          	auipc	a3,0x80007
    800011c0:	e4468693          	addi	a3,a3,-444 # 8000 <_entry-0x7fff8000>
    800011c4:	4605                	li	a2,1
    800011c6:	067e                	slli	a2,a2,0x1f
    800011c8:	85b2                	mv	a1,a2
    800011ca:	8526                	mv	a0,s1
    800011cc:	00000097          	auipc	ra,0x0
    800011d0:	f50080e7          	jalr	-176(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, (uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
    800011d4:	4719                	li	a4,6
    800011d6:	46c5                	li	a3,17
    800011d8:	06ee                	slli	a3,a3,0x1b
    800011da:	412686b3          	sub	a3,a3,s2
    800011de:	864a                	mv	a2,s2
    800011e0:	85ca                	mv	a1,s2
    800011e2:	8526                	mv	a0,s1
    800011e4:	00000097          	auipc	ra,0x0
    800011e8:	f38080e7          	jalr	-200(ra) # 8000111c <kvmmap>
  kvmmap(kpgtbl, TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
    800011ec:	4729                	li	a4,10
    800011ee:	6685                	lui	a3,0x1
    800011f0:	00006617          	auipc	a2,0x6
    800011f4:	e1060613          	addi	a2,a2,-496 # 80007000 <_trampoline>
    800011f8:	040005b7          	lui	a1,0x4000
    800011fc:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    800011fe:	05b2                	slli	a1,a1,0xc
    80001200:	8526                	mv	a0,s1
    80001202:	00000097          	auipc	ra,0x0
    80001206:	f1a080e7          	jalr	-230(ra) # 8000111c <kvmmap>
  proc_mapstacks(kpgtbl);
    8000120a:	8526                	mv	a0,s1
    8000120c:	00000097          	auipc	ra,0x0
    80001210:	644080e7          	jalr	1604(ra) # 80001850 <proc_mapstacks>
}
    80001214:	8526                	mv	a0,s1
    80001216:	60e2                	ld	ra,24(sp)
    80001218:	6442                	ld	s0,16(sp)
    8000121a:	64a2                	ld	s1,8(sp)
    8000121c:	6902                	ld	s2,0(sp)
    8000121e:	6105                	addi	sp,sp,32
    80001220:	8082                	ret

0000000080001222 <kvminit>:
{
    80001222:	1141                	addi	sp,sp,-16
    80001224:	e406                	sd	ra,8(sp)
    80001226:	e022                	sd	s0,0(sp)
    80001228:	0800                	addi	s0,sp,16
  kernel_pagetable = kvmmake();
    8000122a:	00000097          	auipc	ra,0x0
    8000122e:	f22080e7          	jalr	-222(ra) # 8000114c <kvmmake>
    80001232:	00008797          	auipc	a5,0x8
    80001236:	dea7b723          	sd	a0,-530(a5) # 80009020 <kernel_pagetable>
}
    8000123a:	60a2                	ld	ra,8(sp)
    8000123c:	6402                	ld	s0,0(sp)
    8000123e:	0141                	addi	sp,sp,16
    80001240:	8082                	ret

0000000080001242 <uvmunmap>:
// Remove npages of mappings starting from va. va must be
// page-aligned. The mappings must exist.
// Optionally free the physical memory.
void
uvmunmap(pagetable_t pagetable, uint64 va, uint64 npages, int do_free)
{
    80001242:	715d                	addi	sp,sp,-80
    80001244:	e486                	sd	ra,72(sp)
    80001246:	e0a2                	sd	s0,64(sp)
    80001248:	fc26                	sd	s1,56(sp)
    8000124a:	f84a                	sd	s2,48(sp)
    8000124c:	f44e                	sd	s3,40(sp)
    8000124e:	f052                	sd	s4,32(sp)
    80001250:	ec56                	sd	s5,24(sp)
    80001252:	e85a                	sd	s6,16(sp)
    80001254:	e45e                	sd	s7,8(sp)
    80001256:	0880                	addi	s0,sp,80
  uint64 a;
  pte_t *pte;

  if((va % PGSIZE) != 0)
    80001258:	03459793          	slli	a5,a1,0x34
    8000125c:	e795                	bnez	a5,80001288 <uvmunmap+0x46>
    8000125e:	8a2a                	mv	s4,a0
    80001260:	892e                	mv	s2,a1
    80001262:	8ab6                	mv	s5,a3
    panic("uvmunmap: not aligned");

  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    80001264:	0632                	slli	a2,a2,0xc
    80001266:	00b609b3          	add	s3,a2,a1
    if((pte = walk(pagetable, a, 0)) == 0)
      panic("uvmunmap: walk");
    if((*pte & PTE_V) == 0)
      panic("uvmunmap: not mapped");
    if(PTE_FLAGS(*pte) == PTE_V)
    8000126a:	4b85                	li	s7,1
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    8000126c:	6b05                	lui	s6,0x1
    8000126e:	0735e263          	bltu	a1,s3,800012d2 <uvmunmap+0x90>
      uint64 pa = PTE2PA(*pte);
      kfree((void*)pa);
    }
    *pte = 0;
  }
}
    80001272:	60a6                	ld	ra,72(sp)
    80001274:	6406                	ld	s0,64(sp)
    80001276:	74e2                	ld	s1,56(sp)
    80001278:	7942                	ld	s2,48(sp)
    8000127a:	79a2                	ld	s3,40(sp)
    8000127c:	7a02                	ld	s4,32(sp)
    8000127e:	6ae2                	ld	s5,24(sp)
    80001280:	6b42                	ld	s6,16(sp)
    80001282:	6ba2                	ld	s7,8(sp)
    80001284:	6161                	addi	sp,sp,80
    80001286:	8082                	ret
    panic("uvmunmap: not aligned");
    80001288:	00007517          	auipc	a0,0x7
    8000128c:	e6050513          	addi	a0,a0,-416 # 800080e8 <digits+0xa8>
    80001290:	fffff097          	auipc	ra,0xfffff
    80001294:	29c080e7          	jalr	668(ra) # 8000052c <panic>
      panic("uvmunmap: walk");
    80001298:	00007517          	auipc	a0,0x7
    8000129c:	e6850513          	addi	a0,a0,-408 # 80008100 <digits+0xc0>
    800012a0:	fffff097          	auipc	ra,0xfffff
    800012a4:	28c080e7          	jalr	652(ra) # 8000052c <panic>
      panic("uvmunmap: not mapped");
    800012a8:	00007517          	auipc	a0,0x7
    800012ac:	e6850513          	addi	a0,a0,-408 # 80008110 <digits+0xd0>
    800012b0:	fffff097          	auipc	ra,0xfffff
    800012b4:	27c080e7          	jalr	636(ra) # 8000052c <panic>
      panic("uvmunmap: not a leaf");
    800012b8:	00007517          	auipc	a0,0x7
    800012bc:	e7050513          	addi	a0,a0,-400 # 80008128 <digits+0xe8>
    800012c0:	fffff097          	auipc	ra,0xfffff
    800012c4:	26c080e7          	jalr	620(ra) # 8000052c <panic>
    *pte = 0;
    800012c8:	0004b023          	sd	zero,0(s1)
  for(a = va; a < va + npages*PGSIZE; a += PGSIZE){
    800012cc:	995a                	add	s2,s2,s6
    800012ce:	fb3972e3          	bgeu	s2,s3,80001272 <uvmunmap+0x30>
    if((pte = walk(pagetable, a, 0)) == 0)
    800012d2:	4601                	li	a2,0
    800012d4:	85ca                	mv	a1,s2
    800012d6:	8552                	mv	a0,s4
    800012d8:	00000097          	auipc	ra,0x0
    800012dc:	cce080e7          	jalr	-818(ra) # 80000fa6 <walk>
    800012e0:	84aa                	mv	s1,a0
    800012e2:	d95d                	beqz	a0,80001298 <uvmunmap+0x56>
    if((*pte & PTE_V) == 0)
    800012e4:	6108                	ld	a0,0(a0)
    800012e6:	00157793          	andi	a5,a0,1
    800012ea:	dfdd                	beqz	a5,800012a8 <uvmunmap+0x66>
    if(PTE_FLAGS(*pte) == PTE_V)
    800012ec:	3ff57793          	andi	a5,a0,1023
    800012f0:	fd7784e3          	beq	a5,s7,800012b8 <uvmunmap+0x76>
    if(do_free){
    800012f4:	fc0a8ae3          	beqz	s5,800012c8 <uvmunmap+0x86>
      uint64 pa = PTE2PA(*pte);
    800012f8:	8129                	srli	a0,a0,0xa
      kfree((void*)pa);
    800012fa:	0532                	slli	a0,a0,0xc
    800012fc:	fffff097          	auipc	ra,0xfffff
    80001300:	6d8080e7          	jalr	1752(ra) # 800009d4 <kfree>
    80001304:	b7d1                	j	800012c8 <uvmunmap+0x86>

0000000080001306 <uvmcreate>:

// create an empty user page table.
// returns 0 if out of memory.
pagetable_t
uvmcreate()
{
    80001306:	1101                	addi	sp,sp,-32
    80001308:	ec06                	sd	ra,24(sp)
    8000130a:	e822                	sd	s0,16(sp)
    8000130c:	e426                	sd	s1,8(sp)
    8000130e:	1000                	addi	s0,sp,32
  pagetable_t pagetable;
  pagetable = (pagetable_t) kalloc();
    80001310:	fffff097          	auipc	ra,0xfffff
    80001314:	7c2080e7          	jalr	1986(ra) # 80000ad2 <kalloc>
    80001318:	84aa                	mv	s1,a0
  if(pagetable == 0)
    8000131a:	c519                	beqz	a0,80001328 <uvmcreate+0x22>
    return 0;
  memset(pagetable, 0, PGSIZE);
    8000131c:	6605                	lui	a2,0x1
    8000131e:	4581                	li	a1,0
    80001320:	00000097          	auipc	ra,0x0
    80001324:	99e080e7          	jalr	-1634(ra) # 80000cbe <memset>
  return pagetable;
}
    80001328:	8526                	mv	a0,s1
    8000132a:	60e2                	ld	ra,24(sp)
    8000132c:	6442                	ld	s0,16(sp)
    8000132e:	64a2                	ld	s1,8(sp)
    80001330:	6105                	addi	sp,sp,32
    80001332:	8082                	ret

0000000080001334 <uvminit>:
// Load the user initcode into address 0 of pagetable,
// for the very first process.
// sz must be less than a page.
void
uvminit(pagetable_t pagetable, uchar *src, uint sz)
{
    80001334:	7179                	addi	sp,sp,-48
    80001336:	f406                	sd	ra,40(sp)
    80001338:	f022                	sd	s0,32(sp)
    8000133a:	ec26                	sd	s1,24(sp)
    8000133c:	e84a                	sd	s2,16(sp)
    8000133e:	e44e                	sd	s3,8(sp)
    80001340:	e052                	sd	s4,0(sp)
    80001342:	1800                	addi	s0,sp,48
  char *mem;

  if(sz >= PGSIZE)
    80001344:	6785                	lui	a5,0x1
    80001346:	04f67863          	bgeu	a2,a5,80001396 <uvminit+0x62>
    8000134a:	8a2a                	mv	s4,a0
    8000134c:	89ae                	mv	s3,a1
    8000134e:	84b2                	mv	s1,a2
    panic("inituvm: more than a page");
  mem = kalloc();
    80001350:	fffff097          	auipc	ra,0xfffff
    80001354:	782080e7          	jalr	1922(ra) # 80000ad2 <kalloc>
    80001358:	892a                	mv	s2,a0
  memset(mem, 0, PGSIZE);
    8000135a:	6605                	lui	a2,0x1
    8000135c:	4581                	li	a1,0
    8000135e:	00000097          	auipc	ra,0x0
    80001362:	960080e7          	jalr	-1696(ra) # 80000cbe <memset>
  mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
    80001366:	4779                	li	a4,30
    80001368:	86ca                	mv	a3,s2
    8000136a:	6605                	lui	a2,0x1
    8000136c:	4581                	li	a1,0
    8000136e:	8552                	mv	a0,s4
    80001370:	00000097          	auipc	ra,0x0
    80001374:	d1e080e7          	jalr	-738(ra) # 8000108e <mappages>
  memmove(mem, src, sz);
    80001378:	8626                	mv	a2,s1
    8000137a:	85ce                	mv	a1,s3
    8000137c:	854a                	mv	a0,s2
    8000137e:	00000097          	auipc	ra,0x0
    80001382:	99c080e7          	jalr	-1636(ra) # 80000d1a <memmove>
}
    80001386:	70a2                	ld	ra,40(sp)
    80001388:	7402                	ld	s0,32(sp)
    8000138a:	64e2                	ld	s1,24(sp)
    8000138c:	6942                	ld	s2,16(sp)
    8000138e:	69a2                	ld	s3,8(sp)
    80001390:	6a02                	ld	s4,0(sp)
    80001392:	6145                	addi	sp,sp,48
    80001394:	8082                	ret
    panic("inituvm: more than a page");
    80001396:	00007517          	auipc	a0,0x7
    8000139a:	daa50513          	addi	a0,a0,-598 # 80008140 <digits+0x100>
    8000139e:	fffff097          	auipc	ra,0xfffff
    800013a2:	18e080e7          	jalr	398(ra) # 8000052c <panic>

00000000800013a6 <uvmdealloc>:
// newsz.  oldsz and newsz need not be page-aligned, nor does newsz
// need to be less than oldsz.  oldsz can be larger than the actual
// process size.  Returns the new process size.
uint64
uvmdealloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz)
{
    800013a6:	1101                	addi	sp,sp,-32
    800013a8:	ec06                	sd	ra,24(sp)
    800013aa:	e822                	sd	s0,16(sp)
    800013ac:	e426                	sd	s1,8(sp)
    800013ae:	1000                	addi	s0,sp,32
  if(newsz >= oldsz)
    return oldsz;
    800013b0:	84ae                	mv	s1,a1
  if(newsz >= oldsz)
    800013b2:	00b67d63          	bgeu	a2,a1,800013cc <uvmdealloc+0x26>
    800013b6:	84b2                	mv	s1,a2

  if(PGROUNDUP(newsz) < PGROUNDUP(oldsz)){
    800013b8:	6785                	lui	a5,0x1
    800013ba:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    800013bc:	00f60733          	add	a4,a2,a5
    800013c0:	76fd                	lui	a3,0xfffff
    800013c2:	8f75                	and	a4,a4,a3
    800013c4:	97ae                	add	a5,a5,a1
    800013c6:	8ff5                	and	a5,a5,a3
    800013c8:	00f76863          	bltu	a4,a5,800013d8 <uvmdealloc+0x32>
    int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
    uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
  }

  return newsz;
}
    800013cc:	8526                	mv	a0,s1
    800013ce:	60e2                	ld	ra,24(sp)
    800013d0:	6442                	ld	s0,16(sp)
    800013d2:	64a2                	ld	s1,8(sp)
    800013d4:	6105                	addi	sp,sp,32
    800013d6:	8082                	ret
    int npages = (PGROUNDUP(oldsz) - PGROUNDUP(newsz)) / PGSIZE;
    800013d8:	8f99                	sub	a5,a5,a4
    800013da:	83b1                	srli	a5,a5,0xc
    uvmunmap(pagetable, PGROUNDUP(newsz), npages, 1);
    800013dc:	4685                	li	a3,1
    800013de:	0007861b          	sext.w	a2,a5
    800013e2:	85ba                	mv	a1,a4
    800013e4:	00000097          	auipc	ra,0x0
    800013e8:	e5e080e7          	jalr	-418(ra) # 80001242 <uvmunmap>
    800013ec:	b7c5                	j	800013cc <uvmdealloc+0x26>

00000000800013ee <uvmalloc>:
  if(newsz < oldsz)
    800013ee:	0ab66163          	bltu	a2,a1,80001490 <uvmalloc+0xa2>
{
    800013f2:	7139                	addi	sp,sp,-64
    800013f4:	fc06                	sd	ra,56(sp)
    800013f6:	f822                	sd	s0,48(sp)
    800013f8:	f426                	sd	s1,40(sp)
    800013fa:	f04a                	sd	s2,32(sp)
    800013fc:	ec4e                	sd	s3,24(sp)
    800013fe:	e852                	sd	s4,16(sp)
    80001400:	e456                	sd	s5,8(sp)
    80001402:	0080                	addi	s0,sp,64
    80001404:	8aaa                	mv	s5,a0
    80001406:	8a32                	mv	s4,a2
  oldsz = PGROUNDUP(oldsz);
    80001408:	6785                	lui	a5,0x1
    8000140a:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    8000140c:	95be                	add	a1,a1,a5
    8000140e:	77fd                	lui	a5,0xfffff
    80001410:	00f5f9b3          	and	s3,a1,a5
  for(a = oldsz; a < newsz; a += PGSIZE){
    80001414:	08c9f063          	bgeu	s3,a2,80001494 <uvmalloc+0xa6>
    80001418:	894e                	mv	s2,s3
    mem = kalloc();
    8000141a:	fffff097          	auipc	ra,0xfffff
    8000141e:	6b8080e7          	jalr	1720(ra) # 80000ad2 <kalloc>
    80001422:	84aa                	mv	s1,a0
    if(mem == 0){
    80001424:	c51d                	beqz	a0,80001452 <uvmalloc+0x64>
    memset(mem, 0, PGSIZE);
    80001426:	6605                	lui	a2,0x1
    80001428:	4581                	li	a1,0
    8000142a:	00000097          	auipc	ra,0x0
    8000142e:	894080e7          	jalr	-1900(ra) # 80000cbe <memset>
    if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
    80001432:	4779                	li	a4,30
    80001434:	86a6                	mv	a3,s1
    80001436:	6605                	lui	a2,0x1
    80001438:	85ca                	mv	a1,s2
    8000143a:	8556                	mv	a0,s5
    8000143c:	00000097          	auipc	ra,0x0
    80001440:	c52080e7          	jalr	-942(ra) # 8000108e <mappages>
    80001444:	e905                	bnez	a0,80001474 <uvmalloc+0x86>
  for(a = oldsz; a < newsz; a += PGSIZE){
    80001446:	6785                	lui	a5,0x1
    80001448:	993e                	add	s2,s2,a5
    8000144a:	fd4968e3          	bltu	s2,s4,8000141a <uvmalloc+0x2c>
  return newsz;
    8000144e:	8552                	mv	a0,s4
    80001450:	a809                	j	80001462 <uvmalloc+0x74>
      uvmdealloc(pagetable, a, oldsz);
    80001452:	864e                	mv	a2,s3
    80001454:	85ca                	mv	a1,s2
    80001456:	8556                	mv	a0,s5
    80001458:	00000097          	auipc	ra,0x0
    8000145c:	f4e080e7          	jalr	-178(ra) # 800013a6 <uvmdealloc>
      return 0;
    80001460:	4501                	li	a0,0
}
    80001462:	70e2                	ld	ra,56(sp)
    80001464:	7442                	ld	s0,48(sp)
    80001466:	74a2                	ld	s1,40(sp)
    80001468:	7902                	ld	s2,32(sp)
    8000146a:	69e2                	ld	s3,24(sp)
    8000146c:	6a42                	ld	s4,16(sp)
    8000146e:	6aa2                	ld	s5,8(sp)
    80001470:	6121                	addi	sp,sp,64
    80001472:	8082                	ret
      kfree(mem);
    80001474:	8526                	mv	a0,s1
    80001476:	fffff097          	auipc	ra,0xfffff
    8000147a:	55e080e7          	jalr	1374(ra) # 800009d4 <kfree>
      uvmdealloc(pagetable, a, oldsz);
    8000147e:	864e                	mv	a2,s3
    80001480:	85ca                	mv	a1,s2
    80001482:	8556                	mv	a0,s5
    80001484:	00000097          	auipc	ra,0x0
    80001488:	f22080e7          	jalr	-222(ra) # 800013a6 <uvmdealloc>
      return 0;
    8000148c:	4501                	li	a0,0
    8000148e:	bfd1                	j	80001462 <uvmalloc+0x74>
    return oldsz;
    80001490:	852e                	mv	a0,a1
}
    80001492:	8082                	ret
  return newsz;
    80001494:	8532                	mv	a0,a2
    80001496:	b7f1                	j	80001462 <uvmalloc+0x74>

0000000080001498 <freewalk>:

// Recursively free page-table pages.
// All leaf mappings must already have been removed.
void
freewalk(pagetable_t pagetable)
{
    80001498:	7179                	addi	sp,sp,-48
    8000149a:	f406                	sd	ra,40(sp)
    8000149c:	f022                	sd	s0,32(sp)
    8000149e:	ec26                	sd	s1,24(sp)
    800014a0:	e84a                	sd	s2,16(sp)
    800014a2:	e44e                	sd	s3,8(sp)
    800014a4:	e052                	sd	s4,0(sp)
    800014a6:	1800                	addi	s0,sp,48
    800014a8:	8a2a                	mv	s4,a0
  // there are 2^9 = 512 PTEs in a page table.
  for(int i = 0; i < 512; i++){
    800014aa:	84aa                	mv	s1,a0
    800014ac:	6905                	lui	s2,0x1
    800014ae:	992a                	add	s2,s2,a0
    pte_t pte = pagetable[i];
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    800014b0:	4985                	li	s3,1
    800014b2:	a829                	j	800014cc <freewalk+0x34>
      // this PTE points to a lower-level page table.
      uint64 child = PTE2PA(pte);
    800014b4:	83a9                	srli	a5,a5,0xa
      freewalk((pagetable_t)child);
    800014b6:	00c79513          	slli	a0,a5,0xc
    800014ba:	00000097          	auipc	ra,0x0
    800014be:	fde080e7          	jalr	-34(ra) # 80001498 <freewalk>
      pagetable[i] = 0;
    800014c2:	0004b023          	sd	zero,0(s1)
  for(int i = 0; i < 512; i++){
    800014c6:	04a1                	addi	s1,s1,8
    800014c8:	03248163          	beq	s1,s2,800014ea <freewalk+0x52>
    pte_t pte = pagetable[i];
    800014cc:	609c                	ld	a5,0(s1)
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    800014ce:	00f7f713          	andi	a4,a5,15
    800014d2:	ff3701e3          	beq	a4,s3,800014b4 <freewalk+0x1c>
    } else if(pte & PTE_V){
    800014d6:	8b85                	andi	a5,a5,1
    800014d8:	d7fd                	beqz	a5,800014c6 <freewalk+0x2e>
      panic("freewalk: leaf");
    800014da:	00007517          	auipc	a0,0x7
    800014de:	c8650513          	addi	a0,a0,-890 # 80008160 <digits+0x120>
    800014e2:	fffff097          	auipc	ra,0xfffff
    800014e6:	04a080e7          	jalr	74(ra) # 8000052c <panic>
    }
  }
  kfree((void*)pagetable);
    800014ea:	8552                	mv	a0,s4
    800014ec:	fffff097          	auipc	ra,0xfffff
    800014f0:	4e8080e7          	jalr	1256(ra) # 800009d4 <kfree>
}
    800014f4:	70a2                	ld	ra,40(sp)
    800014f6:	7402                	ld	s0,32(sp)
    800014f8:	64e2                	ld	s1,24(sp)
    800014fa:	6942                	ld	s2,16(sp)
    800014fc:	69a2                	ld	s3,8(sp)
    800014fe:	6a02                	ld	s4,0(sp)
    80001500:	6145                	addi	sp,sp,48
    80001502:	8082                	ret

0000000080001504 <uvmfree>:

// Free user memory pages,
// then free page-table pages.
void
uvmfree(pagetable_t pagetable, uint64 sz)
{
    80001504:	1101                	addi	sp,sp,-32
    80001506:	ec06                	sd	ra,24(sp)
    80001508:	e822                	sd	s0,16(sp)
    8000150a:	e426                	sd	s1,8(sp)
    8000150c:	1000                	addi	s0,sp,32
    8000150e:	84aa                	mv	s1,a0
  if(sz > 0)
    80001510:	e999                	bnez	a1,80001526 <uvmfree+0x22>
    uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
  freewalk(pagetable);
    80001512:	8526                	mv	a0,s1
    80001514:	00000097          	auipc	ra,0x0
    80001518:	f84080e7          	jalr	-124(ra) # 80001498 <freewalk>
}
    8000151c:	60e2                	ld	ra,24(sp)
    8000151e:	6442                	ld	s0,16(sp)
    80001520:	64a2                	ld	s1,8(sp)
    80001522:	6105                	addi	sp,sp,32
    80001524:	8082                	ret
    uvmunmap(pagetable, 0, PGROUNDUP(sz)/PGSIZE, 1);
    80001526:	6785                	lui	a5,0x1
    80001528:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    8000152a:	95be                	add	a1,a1,a5
    8000152c:	4685                	li	a3,1
    8000152e:	00c5d613          	srli	a2,a1,0xc
    80001532:	4581                	li	a1,0
    80001534:	00000097          	auipc	ra,0x0
    80001538:	d0e080e7          	jalr	-754(ra) # 80001242 <uvmunmap>
    8000153c:	bfd9                	j	80001512 <uvmfree+0xe>

000000008000153e <uvmcopy>:
  pte_t *pte;
  uint64 pa, i;
  uint flags;
  char *mem;

  for(i = 0; i < sz; i += PGSIZE){
    8000153e:	c679                	beqz	a2,8000160c <uvmcopy+0xce>
{
    80001540:	715d                	addi	sp,sp,-80
    80001542:	e486                	sd	ra,72(sp)
    80001544:	e0a2                	sd	s0,64(sp)
    80001546:	fc26                	sd	s1,56(sp)
    80001548:	f84a                	sd	s2,48(sp)
    8000154a:	f44e                	sd	s3,40(sp)
    8000154c:	f052                	sd	s4,32(sp)
    8000154e:	ec56                	sd	s5,24(sp)
    80001550:	e85a                	sd	s6,16(sp)
    80001552:	e45e                	sd	s7,8(sp)
    80001554:	0880                	addi	s0,sp,80
    80001556:	8b2a                	mv	s6,a0
    80001558:	8aae                	mv	s5,a1
    8000155a:	8a32                	mv	s4,a2
  for(i = 0; i < sz; i += PGSIZE){
    8000155c:	4981                	li	s3,0
    if((pte = walk(old, i, 0)) == 0)
    8000155e:	4601                	li	a2,0
    80001560:	85ce                	mv	a1,s3
    80001562:	855a                	mv	a0,s6
    80001564:	00000097          	auipc	ra,0x0
    80001568:	a42080e7          	jalr	-1470(ra) # 80000fa6 <walk>
    8000156c:	c531                	beqz	a0,800015b8 <uvmcopy+0x7a>
      panic("uvmcopy: pte should exist");
    if((*pte & PTE_V) == 0)
    8000156e:	6118                	ld	a4,0(a0)
    80001570:	00177793          	andi	a5,a4,1
    80001574:	cbb1                	beqz	a5,800015c8 <uvmcopy+0x8a>
      panic("uvmcopy: page not present");
    pa = PTE2PA(*pte);
    80001576:	00a75593          	srli	a1,a4,0xa
    8000157a:	00c59b93          	slli	s7,a1,0xc
    flags = PTE_FLAGS(*pte);
    8000157e:	3ff77493          	andi	s1,a4,1023
    if((mem = kalloc()) == 0)
    80001582:	fffff097          	auipc	ra,0xfffff
    80001586:	550080e7          	jalr	1360(ra) # 80000ad2 <kalloc>
    8000158a:	892a                	mv	s2,a0
    8000158c:	c939                	beqz	a0,800015e2 <uvmcopy+0xa4>
      goto err;
    memmove(mem, (char*)pa, PGSIZE);
    8000158e:	6605                	lui	a2,0x1
    80001590:	85de                	mv	a1,s7
    80001592:	fffff097          	auipc	ra,0xfffff
    80001596:	788080e7          	jalr	1928(ra) # 80000d1a <memmove>
    if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0){
    8000159a:	8726                	mv	a4,s1
    8000159c:	86ca                	mv	a3,s2
    8000159e:	6605                	lui	a2,0x1
    800015a0:	85ce                	mv	a1,s3
    800015a2:	8556                	mv	a0,s5
    800015a4:	00000097          	auipc	ra,0x0
    800015a8:	aea080e7          	jalr	-1302(ra) # 8000108e <mappages>
    800015ac:	e515                	bnez	a0,800015d8 <uvmcopy+0x9a>
  for(i = 0; i < sz; i += PGSIZE){
    800015ae:	6785                	lui	a5,0x1
    800015b0:	99be                	add	s3,s3,a5
    800015b2:	fb49e6e3          	bltu	s3,s4,8000155e <uvmcopy+0x20>
    800015b6:	a081                	j	800015f6 <uvmcopy+0xb8>
      panic("uvmcopy: pte should exist");
    800015b8:	00007517          	auipc	a0,0x7
    800015bc:	bb850513          	addi	a0,a0,-1096 # 80008170 <digits+0x130>
    800015c0:	fffff097          	auipc	ra,0xfffff
    800015c4:	f6c080e7          	jalr	-148(ra) # 8000052c <panic>
      panic("uvmcopy: page not present");
    800015c8:	00007517          	auipc	a0,0x7
    800015cc:	bc850513          	addi	a0,a0,-1080 # 80008190 <digits+0x150>
    800015d0:	fffff097          	auipc	ra,0xfffff
    800015d4:	f5c080e7          	jalr	-164(ra) # 8000052c <panic>
      kfree(mem);
    800015d8:	854a                	mv	a0,s2
    800015da:	fffff097          	auipc	ra,0xfffff
    800015de:	3fa080e7          	jalr	1018(ra) # 800009d4 <kfree>
    }
  }
  return 0;

 err:
  uvmunmap(new, 0, i / PGSIZE, 1);
    800015e2:	4685                	li	a3,1
    800015e4:	00c9d613          	srli	a2,s3,0xc
    800015e8:	4581                	li	a1,0
    800015ea:	8556                	mv	a0,s5
    800015ec:	00000097          	auipc	ra,0x0
    800015f0:	c56080e7          	jalr	-938(ra) # 80001242 <uvmunmap>
  return -1;
    800015f4:	557d                	li	a0,-1
}
    800015f6:	60a6                	ld	ra,72(sp)
    800015f8:	6406                	ld	s0,64(sp)
    800015fa:	74e2                	ld	s1,56(sp)
    800015fc:	7942                	ld	s2,48(sp)
    800015fe:	79a2                	ld	s3,40(sp)
    80001600:	7a02                	ld	s4,32(sp)
    80001602:	6ae2                	ld	s5,24(sp)
    80001604:	6b42                	ld	s6,16(sp)
    80001606:	6ba2                	ld	s7,8(sp)
    80001608:	6161                	addi	sp,sp,80
    8000160a:	8082                	ret
  return 0;
    8000160c:	4501                	li	a0,0
}
    8000160e:	8082                	ret

0000000080001610 <uvmclear>:

// mark a PTE invalid for user access.
// used by exec for the user stack guard page.
void
uvmclear(pagetable_t pagetable, uint64 va)
{
    80001610:	1141                	addi	sp,sp,-16
    80001612:	e406                	sd	ra,8(sp)
    80001614:	e022                	sd	s0,0(sp)
    80001616:	0800                	addi	s0,sp,16
  pte_t *pte;
  
  pte = walk(pagetable, va, 0);
    80001618:	4601                	li	a2,0
    8000161a:	00000097          	auipc	ra,0x0
    8000161e:	98c080e7          	jalr	-1652(ra) # 80000fa6 <walk>
  if(pte == 0)
    80001622:	c901                	beqz	a0,80001632 <uvmclear+0x22>
    panic("uvmclear");
  *pte &= ~PTE_U;
    80001624:	611c                	ld	a5,0(a0)
    80001626:	9bbd                	andi	a5,a5,-17
    80001628:	e11c                	sd	a5,0(a0)
}
    8000162a:	60a2                	ld	ra,8(sp)
    8000162c:	6402                	ld	s0,0(sp)
    8000162e:	0141                	addi	sp,sp,16
    80001630:	8082                	ret
    panic("uvmclear");
    80001632:	00007517          	auipc	a0,0x7
    80001636:	b7e50513          	addi	a0,a0,-1154 # 800081b0 <digits+0x170>
    8000163a:	fffff097          	auipc	ra,0xfffff
    8000163e:	ef2080e7          	jalr	-270(ra) # 8000052c <panic>

0000000080001642 <copyout>:
int
copyout(pagetable_t pagetable, uint64 dstva, char *src, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    80001642:	c6bd                	beqz	a3,800016b0 <copyout+0x6e>
{
    80001644:	715d                	addi	sp,sp,-80
    80001646:	e486                	sd	ra,72(sp)
    80001648:	e0a2                	sd	s0,64(sp)
    8000164a:	fc26                	sd	s1,56(sp)
    8000164c:	f84a                	sd	s2,48(sp)
    8000164e:	f44e                	sd	s3,40(sp)
    80001650:	f052                	sd	s4,32(sp)
    80001652:	ec56                	sd	s5,24(sp)
    80001654:	e85a                	sd	s6,16(sp)
    80001656:	e45e                	sd	s7,8(sp)
    80001658:	e062                	sd	s8,0(sp)
    8000165a:	0880                	addi	s0,sp,80
    8000165c:	8b2a                	mv	s6,a0
    8000165e:	8c2e                	mv	s8,a1
    80001660:	8a32                	mv	s4,a2
    80001662:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(dstva);
    80001664:	7bfd                	lui	s7,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (dstva - va0);
    80001666:	6a85                	lui	s5,0x1
    80001668:	a015                	j	8000168c <copyout+0x4a>
    if(n > len)
      n = len;
    memmove((void *)(pa0 + (dstva - va0)), src, n);
    8000166a:	9562                	add	a0,a0,s8
    8000166c:	0004861b          	sext.w	a2,s1
    80001670:	85d2                	mv	a1,s4
    80001672:	41250533          	sub	a0,a0,s2
    80001676:	fffff097          	auipc	ra,0xfffff
    8000167a:	6a4080e7          	jalr	1700(ra) # 80000d1a <memmove>

    len -= n;
    8000167e:	409989b3          	sub	s3,s3,s1
    src += n;
    80001682:	9a26                	add	s4,s4,s1
    dstva = va0 + PGSIZE;
    80001684:	01590c33          	add	s8,s2,s5
  while(len > 0){
    80001688:	02098263          	beqz	s3,800016ac <copyout+0x6a>
    va0 = PGROUNDDOWN(dstva);
    8000168c:	017c7933          	and	s2,s8,s7
    pa0 = walkaddr(pagetable, va0);
    80001690:	85ca                	mv	a1,s2
    80001692:	855a                	mv	a0,s6
    80001694:	00000097          	auipc	ra,0x0
    80001698:	9b8080e7          	jalr	-1608(ra) # 8000104c <walkaddr>
    if(pa0 == 0)
    8000169c:	cd01                	beqz	a0,800016b4 <copyout+0x72>
    n = PGSIZE - (dstva - va0);
    8000169e:	418904b3          	sub	s1,s2,s8
    800016a2:	94d6                	add	s1,s1,s5
    800016a4:	fc99f3e3          	bgeu	s3,s1,8000166a <copyout+0x28>
    800016a8:	84ce                	mv	s1,s3
    800016aa:	b7c1                	j	8000166a <copyout+0x28>
  }
  return 0;
    800016ac:	4501                	li	a0,0
    800016ae:	a021                	j	800016b6 <copyout+0x74>
    800016b0:	4501                	li	a0,0
}
    800016b2:	8082                	ret
      return -1;
    800016b4:	557d                	li	a0,-1
}
    800016b6:	60a6                	ld	ra,72(sp)
    800016b8:	6406                	ld	s0,64(sp)
    800016ba:	74e2                	ld	s1,56(sp)
    800016bc:	7942                	ld	s2,48(sp)
    800016be:	79a2                	ld	s3,40(sp)
    800016c0:	7a02                	ld	s4,32(sp)
    800016c2:	6ae2                	ld	s5,24(sp)
    800016c4:	6b42                	ld	s6,16(sp)
    800016c6:	6ba2                	ld	s7,8(sp)
    800016c8:	6c02                	ld	s8,0(sp)
    800016ca:	6161                	addi	sp,sp,80
    800016cc:	8082                	ret

00000000800016ce <copyin>:
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    800016ce:	caa5                	beqz	a3,8000173e <copyin+0x70>
{
    800016d0:	715d                	addi	sp,sp,-80
    800016d2:	e486                	sd	ra,72(sp)
    800016d4:	e0a2                	sd	s0,64(sp)
    800016d6:	fc26                	sd	s1,56(sp)
    800016d8:	f84a                	sd	s2,48(sp)
    800016da:	f44e                	sd	s3,40(sp)
    800016dc:	f052                	sd	s4,32(sp)
    800016de:	ec56                	sd	s5,24(sp)
    800016e0:	e85a                	sd	s6,16(sp)
    800016e2:	e45e                	sd	s7,8(sp)
    800016e4:	e062                	sd	s8,0(sp)
    800016e6:	0880                	addi	s0,sp,80
    800016e8:	8b2a                	mv	s6,a0
    800016ea:	8a2e                	mv	s4,a1
    800016ec:	8c32                	mv	s8,a2
    800016ee:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(srcva);
    800016f0:	7bfd                	lui	s7,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    800016f2:	6a85                	lui	s5,0x1
    800016f4:	a01d                	j	8000171a <copyin+0x4c>
    if(n > len)
      n = len;
    memmove(dst, (void *)(pa0 + (srcva - va0)), n);
    800016f6:	018505b3          	add	a1,a0,s8
    800016fa:	0004861b          	sext.w	a2,s1
    800016fe:	412585b3          	sub	a1,a1,s2
    80001702:	8552                	mv	a0,s4
    80001704:	fffff097          	auipc	ra,0xfffff
    80001708:	616080e7          	jalr	1558(ra) # 80000d1a <memmove>

    len -= n;
    8000170c:	409989b3          	sub	s3,s3,s1
    dst += n;
    80001710:	9a26                	add	s4,s4,s1
    srcva = va0 + PGSIZE;
    80001712:	01590c33          	add	s8,s2,s5
  while(len > 0){
    80001716:	02098263          	beqz	s3,8000173a <copyin+0x6c>
    va0 = PGROUNDDOWN(srcva);
    8000171a:	017c7933          	and	s2,s8,s7
    pa0 = walkaddr(pagetable, va0);
    8000171e:	85ca                	mv	a1,s2
    80001720:	855a                	mv	a0,s6
    80001722:	00000097          	auipc	ra,0x0
    80001726:	92a080e7          	jalr	-1750(ra) # 8000104c <walkaddr>
    if(pa0 == 0)
    8000172a:	cd01                	beqz	a0,80001742 <copyin+0x74>
    n = PGSIZE - (srcva - va0);
    8000172c:	418904b3          	sub	s1,s2,s8
    80001730:	94d6                	add	s1,s1,s5
    80001732:	fc99f2e3          	bgeu	s3,s1,800016f6 <copyin+0x28>
    80001736:	84ce                	mv	s1,s3
    80001738:	bf7d                	j	800016f6 <copyin+0x28>
  }
  return 0;
    8000173a:	4501                	li	a0,0
    8000173c:	a021                	j	80001744 <copyin+0x76>
    8000173e:	4501                	li	a0,0
}
    80001740:	8082                	ret
      return -1;
    80001742:	557d                	li	a0,-1
}
    80001744:	60a6                	ld	ra,72(sp)
    80001746:	6406                	ld	s0,64(sp)
    80001748:	74e2                	ld	s1,56(sp)
    8000174a:	7942                	ld	s2,48(sp)
    8000174c:	79a2                	ld	s3,40(sp)
    8000174e:	7a02                	ld	s4,32(sp)
    80001750:	6ae2                	ld	s5,24(sp)
    80001752:	6b42                	ld	s6,16(sp)
    80001754:	6ba2                	ld	s7,8(sp)
    80001756:	6c02                	ld	s8,0(sp)
    80001758:	6161                	addi	sp,sp,80
    8000175a:	8082                	ret

000000008000175c <copyinstr>:
copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max)
{
  uint64 n, va0, pa0;
  int got_null = 0;

  while(got_null == 0 && max > 0){
    8000175c:	c2dd                	beqz	a3,80001802 <copyinstr+0xa6>
{
    8000175e:	715d                	addi	sp,sp,-80
    80001760:	e486                	sd	ra,72(sp)
    80001762:	e0a2                	sd	s0,64(sp)
    80001764:	fc26                	sd	s1,56(sp)
    80001766:	f84a                	sd	s2,48(sp)
    80001768:	f44e                	sd	s3,40(sp)
    8000176a:	f052                	sd	s4,32(sp)
    8000176c:	ec56                	sd	s5,24(sp)
    8000176e:	e85a                	sd	s6,16(sp)
    80001770:	e45e                	sd	s7,8(sp)
    80001772:	0880                	addi	s0,sp,80
    80001774:	8a2a                	mv	s4,a0
    80001776:	8b2e                	mv	s6,a1
    80001778:	8bb2                	mv	s7,a2
    8000177a:	84b6                	mv	s1,a3
    va0 = PGROUNDDOWN(srcva);
    8000177c:	7afd                	lui	s5,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    8000177e:	6985                	lui	s3,0x1
    80001780:	a02d                	j	800017aa <copyinstr+0x4e>
      n = max;

    char *p = (char *) (pa0 + (srcva - va0));
    while(n > 0){
      if(*p == '\0'){
        *dst = '\0';
    80001782:	00078023          	sb	zero,0(a5) # 1000 <_entry-0x7ffff000>
    80001786:	4785                	li	a5,1
      dst++;
    }

    srcva = va0 + PGSIZE;
  }
  if(got_null){
    80001788:	37fd                	addiw	a5,a5,-1
    8000178a:	0007851b          	sext.w	a0,a5
    return 0;
  } else {
    return -1;
  }
}
    8000178e:	60a6                	ld	ra,72(sp)
    80001790:	6406                	ld	s0,64(sp)
    80001792:	74e2                	ld	s1,56(sp)
    80001794:	7942                	ld	s2,48(sp)
    80001796:	79a2                	ld	s3,40(sp)
    80001798:	7a02                	ld	s4,32(sp)
    8000179a:	6ae2                	ld	s5,24(sp)
    8000179c:	6b42                	ld	s6,16(sp)
    8000179e:	6ba2                	ld	s7,8(sp)
    800017a0:	6161                	addi	sp,sp,80
    800017a2:	8082                	ret
    srcva = va0 + PGSIZE;
    800017a4:	01390bb3          	add	s7,s2,s3
  while(got_null == 0 && max > 0){
    800017a8:	c8a9                	beqz	s1,800017fa <copyinstr+0x9e>
    va0 = PGROUNDDOWN(srcva);
    800017aa:	015bf933          	and	s2,s7,s5
    pa0 = walkaddr(pagetable, va0);
    800017ae:	85ca                	mv	a1,s2
    800017b0:	8552                	mv	a0,s4
    800017b2:	00000097          	auipc	ra,0x0
    800017b6:	89a080e7          	jalr	-1894(ra) # 8000104c <walkaddr>
    if(pa0 == 0)
    800017ba:	c131                	beqz	a0,800017fe <copyinstr+0xa2>
    n = PGSIZE - (srcva - va0);
    800017bc:	417906b3          	sub	a3,s2,s7
    800017c0:	96ce                	add	a3,a3,s3
    800017c2:	00d4f363          	bgeu	s1,a3,800017c8 <copyinstr+0x6c>
    800017c6:	86a6                	mv	a3,s1
    char *p = (char *) (pa0 + (srcva - va0));
    800017c8:	955e                	add	a0,a0,s7
    800017ca:	41250533          	sub	a0,a0,s2
    while(n > 0){
    800017ce:	daf9                	beqz	a3,800017a4 <copyinstr+0x48>
    800017d0:	87da                	mv	a5,s6
      if(*p == '\0'){
    800017d2:	41650633          	sub	a2,a0,s6
    800017d6:	fff48593          	addi	a1,s1,-1
    800017da:	95da                	add	a1,a1,s6
    while(n > 0){
    800017dc:	96da                	add	a3,a3,s6
      if(*p == '\0'){
    800017de:	00f60733          	add	a4,a2,a5
    800017e2:	00074703          	lbu	a4,0(a4) # fffffffffffff000 <end+0xffffffff7ffde000>
    800017e6:	df51                	beqz	a4,80001782 <copyinstr+0x26>
        *dst = *p;
    800017e8:	00e78023          	sb	a4,0(a5)
      --max;
    800017ec:	40f584b3          	sub	s1,a1,a5
      dst++;
    800017f0:	0785                	addi	a5,a5,1
    while(n > 0){
    800017f2:	fed796e3          	bne	a5,a3,800017de <copyinstr+0x82>
      dst++;
    800017f6:	8b3e                	mv	s6,a5
    800017f8:	b775                	j	800017a4 <copyinstr+0x48>
    800017fa:	4781                	li	a5,0
    800017fc:	b771                	j	80001788 <copyinstr+0x2c>
      return -1;
    800017fe:	557d                	li	a0,-1
    80001800:	b779                	j	8000178e <copyinstr+0x32>
  int got_null = 0;
    80001802:	4781                	li	a5,0
  if(got_null){
    80001804:	37fd                	addiw	a5,a5,-1
    80001806:	0007851b          	sext.w	a0,a5
}
    8000180a:	8082                	ret

000000008000180c <wakeup1>:

// Wake up p if it is sleeping in wait(); used by exit().
// Caller must hold p->lock.
static void
wakeup1(struct proc *p)
{
    8000180c:	1101                	addi	sp,sp,-32
    8000180e:	ec06                	sd	ra,24(sp)
    80001810:	e822                	sd	s0,16(sp)
    80001812:	e426                	sd	s1,8(sp)
    80001814:	1000                	addi	s0,sp,32
    80001816:	84aa                	mv	s1,a0
  if(!holding(&p->lock))
    80001818:	fffff097          	auipc	ra,0xfffff
    8000181c:	330080e7          	jalr	816(ra) # 80000b48 <holding>
    80001820:	c909                	beqz	a0,80001832 <wakeup1+0x26>
    panic("wakeup1");
  if(p->chan == p && p->state == SLEEPING) {
    80001822:	749c                	ld	a5,40(s1)
    80001824:	00978f63          	beq	a5,s1,80001842 <wakeup1+0x36>
    p->state = RUNNABLE;
  }
}
    80001828:	60e2                	ld	ra,24(sp)
    8000182a:	6442                	ld	s0,16(sp)
    8000182c:	64a2                	ld	s1,8(sp)
    8000182e:	6105                	addi	sp,sp,32
    80001830:	8082                	ret
    panic("wakeup1");
    80001832:	00007517          	auipc	a0,0x7
    80001836:	98e50513          	addi	a0,a0,-1650 # 800081c0 <digits+0x180>
    8000183a:	fffff097          	auipc	ra,0xfffff
    8000183e:	cf2080e7          	jalr	-782(ra) # 8000052c <panic>
  if(p->chan == p && p->state == SLEEPING) {
    80001842:	4c98                	lw	a4,24(s1)
    80001844:	4785                	li	a5,1
    80001846:	fef711e3          	bne	a4,a5,80001828 <wakeup1+0x1c>
    p->state = RUNNABLE;
    8000184a:	4789                	li	a5,2
    8000184c:	cc9c                	sw	a5,24(s1)
}
    8000184e:	bfe9                	j	80001828 <wakeup1+0x1c>

0000000080001850 <proc_mapstacks>:
proc_mapstacks(pagetable_t kpgtbl) {
    80001850:	7139                	addi	sp,sp,-64
    80001852:	fc06                	sd	ra,56(sp)
    80001854:	f822                	sd	s0,48(sp)
    80001856:	f426                	sd	s1,40(sp)
    80001858:	f04a                	sd	s2,32(sp)
    8000185a:	ec4e                	sd	s3,24(sp)
    8000185c:	e852                	sd	s4,16(sp)
    8000185e:	e456                	sd	s5,8(sp)
    80001860:	e05a                	sd	s6,0(sp)
    80001862:	0080                	addi	s0,sp,64
    80001864:	89aa                	mv	s3,a0
  for(p = proc; p < &proc[NPROC]; p++) {
    80001866:	00010497          	auipc	s1,0x10
    8000186a:	e5248493          	addi	s1,s1,-430 # 800116b8 <proc>
    uint64 va = KSTACK((int) (p - proc));
    8000186e:	8b26                	mv	s6,s1
    80001870:	00006a97          	auipc	s5,0x6
    80001874:	790a8a93          	addi	s5,s5,1936 # 80008000 <etext>
    80001878:	04000937          	lui	s2,0x4000
    8000187c:	197d                	addi	s2,s2,-1 # 3ffffff <_entry-0x7c000001>
    8000187e:	0932                	slli	s2,s2,0xc
  for(p = proc; p < &proc[NPROC]; p++) {
    80001880:	00011a17          	auipc	s4,0x11
    80001884:	c48a0a13          	addi	s4,s4,-952 # 800124c8 <tickslock>
    char *pa = kalloc();
    80001888:	fffff097          	auipc	ra,0xfffff
    8000188c:	24a080e7          	jalr	586(ra) # 80000ad2 <kalloc>
    80001890:	862a                	mv	a2,a0
    if(pa == 0)
    80001892:	c131                	beqz	a0,800018d6 <proc_mapstacks+0x86>
    uint64 va = KSTACK((int) (p - proc));
    80001894:	416485b3          	sub	a1,s1,s6
    80001898:	858d                	srai	a1,a1,0x3
    8000189a:	000ab783          	ld	a5,0(s5)
    8000189e:	02f585b3          	mul	a1,a1,a5
    800018a2:	2585                	addiw	a1,a1,1
    800018a4:	00d5959b          	slliw	a1,a1,0xd
    kvmmap(kpgtbl, va, (uint64)pa, PGSIZE, PTE_R | PTE_W);
    800018a8:	4719                	li	a4,6
    800018aa:	6685                	lui	a3,0x1
    800018ac:	40b905b3          	sub	a1,s2,a1
    800018b0:	854e                	mv	a0,s3
    800018b2:	00000097          	auipc	ra,0x0
    800018b6:	86a080e7          	jalr	-1942(ra) # 8000111c <kvmmap>
  for(p = proc; p < &proc[NPROC]; p++) {
    800018ba:	16848493          	addi	s1,s1,360
    800018be:	fd4495e3          	bne	s1,s4,80001888 <proc_mapstacks+0x38>
}
    800018c2:	70e2                	ld	ra,56(sp)
    800018c4:	7442                	ld	s0,48(sp)
    800018c6:	74a2                	ld	s1,40(sp)
    800018c8:	7902                	ld	s2,32(sp)
    800018ca:	69e2                	ld	s3,24(sp)
    800018cc:	6a42                	ld	s4,16(sp)
    800018ce:	6aa2                	ld	s5,8(sp)
    800018d0:	6b02                	ld	s6,0(sp)
    800018d2:	6121                	addi	sp,sp,64
    800018d4:	8082                	ret
      panic("kalloc");
    800018d6:	00007517          	auipc	a0,0x7
    800018da:	8f250513          	addi	a0,a0,-1806 # 800081c8 <digits+0x188>
    800018de:	fffff097          	auipc	ra,0xfffff
    800018e2:	c4e080e7          	jalr	-946(ra) # 8000052c <panic>

00000000800018e6 <procinit>:
{
    800018e6:	7139                	addi	sp,sp,-64
    800018e8:	fc06                	sd	ra,56(sp)
    800018ea:	f822                	sd	s0,48(sp)
    800018ec:	f426                	sd	s1,40(sp)
    800018ee:	f04a                	sd	s2,32(sp)
    800018f0:	ec4e                	sd	s3,24(sp)
    800018f2:	e852                	sd	s4,16(sp)
    800018f4:	e456                	sd	s5,8(sp)
    800018f6:	e05a                	sd	s6,0(sp)
    800018f8:	0080                	addi	s0,sp,64
  initlock(&pid_lock, "nextpid");
    800018fa:	00007597          	auipc	a1,0x7
    800018fe:	8d658593          	addi	a1,a1,-1834 # 800081d0 <digits+0x190>
    80001902:	00010517          	auipc	a0,0x10
    80001906:	99e50513          	addi	a0,a0,-1634 # 800112a0 <pid_lock>
    8000190a:	fffff097          	auipc	ra,0xfffff
    8000190e:	228080e7          	jalr	552(ra) # 80000b32 <initlock>
  for(p = proc; p < &proc[NPROC]; p++) {
    80001912:	00010497          	auipc	s1,0x10
    80001916:	da648493          	addi	s1,s1,-602 # 800116b8 <proc>
      initlock(&p->lock, "proc");
    8000191a:	00007b17          	auipc	s6,0x7
    8000191e:	8beb0b13          	addi	s6,s6,-1858 # 800081d8 <digits+0x198>
      p->kstack = KSTACK((int) (p - proc));
    80001922:	8aa6                	mv	s5,s1
    80001924:	00006a17          	auipc	s4,0x6
    80001928:	6dca0a13          	addi	s4,s4,1756 # 80008000 <etext>
    8000192c:	04000937          	lui	s2,0x4000
    80001930:	197d                	addi	s2,s2,-1 # 3ffffff <_entry-0x7c000001>
    80001932:	0932                	slli	s2,s2,0xc
  for(p = proc; p < &proc[NPROC]; p++) {
    80001934:	00011997          	auipc	s3,0x11
    80001938:	b9498993          	addi	s3,s3,-1132 # 800124c8 <tickslock>
      initlock(&p->lock, "proc");
    8000193c:	85da                	mv	a1,s6
    8000193e:	8526                	mv	a0,s1
    80001940:	fffff097          	auipc	ra,0xfffff
    80001944:	1f2080e7          	jalr	498(ra) # 80000b32 <initlock>
      p->kstack = KSTACK((int) (p - proc));
    80001948:	415487b3          	sub	a5,s1,s5
    8000194c:	878d                	srai	a5,a5,0x3
    8000194e:	000a3703          	ld	a4,0(s4)
    80001952:	02e787b3          	mul	a5,a5,a4
    80001956:	2785                	addiw	a5,a5,1
    80001958:	00d7979b          	slliw	a5,a5,0xd
    8000195c:	40f907b3          	sub	a5,s2,a5
    80001960:	e0bc                	sd	a5,64(s1)
  for(p = proc; p < &proc[NPROC]; p++) {
    80001962:	16848493          	addi	s1,s1,360
    80001966:	fd349be3          	bne	s1,s3,8000193c <procinit+0x56>
}
    8000196a:	70e2                	ld	ra,56(sp)
    8000196c:	7442                	ld	s0,48(sp)
    8000196e:	74a2                	ld	s1,40(sp)
    80001970:	7902                	ld	s2,32(sp)
    80001972:	69e2                	ld	s3,24(sp)
    80001974:	6a42                	ld	s4,16(sp)
    80001976:	6aa2                	ld	s5,8(sp)
    80001978:	6b02                	ld	s6,0(sp)
    8000197a:	6121                	addi	sp,sp,64
    8000197c:	8082                	ret

000000008000197e <cpuid>:
{
    8000197e:	1141                	addi	sp,sp,-16
    80001980:	e422                	sd	s0,8(sp)
    80001982:	0800                	addi	s0,sp,16
  asm volatile("mv %0, tp" : "=r" (x) );
    80001984:	8512                	mv	a0,tp
}
    80001986:	2501                	sext.w	a0,a0
    80001988:	6422                	ld	s0,8(sp)
    8000198a:	0141                	addi	sp,sp,16
    8000198c:	8082                	ret

000000008000198e <mycpu>:
mycpu(void) {
    8000198e:	1141                	addi	sp,sp,-16
    80001990:	e422                	sd	s0,8(sp)
    80001992:	0800                	addi	s0,sp,16
    80001994:	8792                	mv	a5,tp
  struct cpu *c = &cpus[id];
    80001996:	2781                	sext.w	a5,a5
    80001998:	079e                	slli	a5,a5,0x7
}
    8000199a:	00010517          	auipc	a0,0x10
    8000199e:	91e50513          	addi	a0,a0,-1762 # 800112b8 <cpus>
    800019a2:	953e                	add	a0,a0,a5
    800019a4:	6422                	ld	s0,8(sp)
    800019a6:	0141                	addi	sp,sp,16
    800019a8:	8082                	ret

00000000800019aa <myproc>:
myproc(void) {
    800019aa:	1101                	addi	sp,sp,-32
    800019ac:	ec06                	sd	ra,24(sp)
    800019ae:	e822                	sd	s0,16(sp)
    800019b0:	e426                	sd	s1,8(sp)
    800019b2:	1000                	addi	s0,sp,32
  push_off();
    800019b4:	fffff097          	auipc	ra,0xfffff
    800019b8:	1c2080e7          	jalr	450(ra) # 80000b76 <push_off>
    800019bc:	8792                	mv	a5,tp
  struct proc *p = c->proc;
    800019be:	2781                	sext.w	a5,a5
    800019c0:	079e                	slli	a5,a5,0x7
    800019c2:	00010717          	auipc	a4,0x10
    800019c6:	8de70713          	addi	a4,a4,-1826 # 800112a0 <pid_lock>
    800019ca:	97ba                	add	a5,a5,a4
    800019cc:	6f84                	ld	s1,24(a5)
  pop_off();
    800019ce:	fffff097          	auipc	ra,0xfffff
    800019d2:	248080e7          	jalr	584(ra) # 80000c16 <pop_off>
}
    800019d6:	8526                	mv	a0,s1
    800019d8:	60e2                	ld	ra,24(sp)
    800019da:	6442                	ld	s0,16(sp)
    800019dc:	64a2                	ld	s1,8(sp)
    800019de:	6105                	addi	sp,sp,32
    800019e0:	8082                	ret

00000000800019e2 <forkret>:
{
    800019e2:	1141                	addi	sp,sp,-16
    800019e4:	e406                	sd	ra,8(sp)
    800019e6:	e022                	sd	s0,0(sp)
    800019e8:	0800                	addi	s0,sp,16
  release(&myproc()->lock);
    800019ea:	00000097          	auipc	ra,0x0
    800019ee:	fc0080e7          	jalr	-64(ra) # 800019aa <myproc>
    800019f2:	fffff097          	auipc	ra,0xfffff
    800019f6:	284080e7          	jalr	644(ra) # 80000c76 <release>
  if (first) {
    800019fa:	00007797          	auipc	a5,0x7
    800019fe:	dc67a783          	lw	a5,-570(a5) # 800087c0 <first.1>
    80001a02:	eb89                	bnez	a5,80001a14 <forkret+0x32>
  usertrapret();
    80001a04:	00001097          	auipc	ra,0x1
    80001a08:	c1e080e7          	jalr	-994(ra) # 80002622 <usertrapret>
}
    80001a0c:	60a2                	ld	ra,8(sp)
    80001a0e:	6402                	ld	s0,0(sp)
    80001a10:	0141                	addi	sp,sp,16
    80001a12:	8082                	ret
    first = 0;
    80001a14:	00007797          	auipc	a5,0x7
    80001a18:	da07a623          	sw	zero,-596(a5) # 800087c0 <first.1>
    fsinit(ROOTDEV);
    80001a1c:	4505                	li	a0,1
    80001a1e:	00002097          	auipc	ra,0x2
    80001a22:	a0c080e7          	jalr	-1524(ra) # 8000342a <fsinit>
    80001a26:	bff9                	j	80001a04 <forkret+0x22>

0000000080001a28 <allocpid>:
allocpid() {
    80001a28:	1101                	addi	sp,sp,-32
    80001a2a:	ec06                	sd	ra,24(sp)
    80001a2c:	e822                	sd	s0,16(sp)
    80001a2e:	e426                	sd	s1,8(sp)
    80001a30:	e04a                	sd	s2,0(sp)
    80001a32:	1000                	addi	s0,sp,32
  acquire(&pid_lock);
    80001a34:	00010917          	auipc	s2,0x10
    80001a38:	86c90913          	addi	s2,s2,-1940 # 800112a0 <pid_lock>
    80001a3c:	854a                	mv	a0,s2
    80001a3e:	fffff097          	auipc	ra,0xfffff
    80001a42:	184080e7          	jalr	388(ra) # 80000bc2 <acquire>
  pid = nextpid;
    80001a46:	00007797          	auipc	a5,0x7
    80001a4a:	d7e78793          	addi	a5,a5,-642 # 800087c4 <nextpid>
    80001a4e:	4384                	lw	s1,0(a5)
  nextpid = nextpid + 1;
    80001a50:	0014871b          	addiw	a4,s1,1
    80001a54:	c398                	sw	a4,0(a5)
  release(&pid_lock);
    80001a56:	854a                	mv	a0,s2
    80001a58:	fffff097          	auipc	ra,0xfffff
    80001a5c:	21e080e7          	jalr	542(ra) # 80000c76 <release>
}
    80001a60:	8526                	mv	a0,s1
    80001a62:	60e2                	ld	ra,24(sp)
    80001a64:	6442                	ld	s0,16(sp)
    80001a66:	64a2                	ld	s1,8(sp)
    80001a68:	6902                	ld	s2,0(sp)
    80001a6a:	6105                	addi	sp,sp,32
    80001a6c:	8082                	ret

0000000080001a6e <proc_pagetable>:
{
    80001a6e:	1101                	addi	sp,sp,-32
    80001a70:	ec06                	sd	ra,24(sp)
    80001a72:	e822                	sd	s0,16(sp)
    80001a74:	e426                	sd	s1,8(sp)
    80001a76:	e04a                	sd	s2,0(sp)
    80001a78:	1000                	addi	s0,sp,32
    80001a7a:	892a                	mv	s2,a0
  pagetable = uvmcreate();
    80001a7c:	00000097          	auipc	ra,0x0
    80001a80:	88a080e7          	jalr	-1910(ra) # 80001306 <uvmcreate>
    80001a84:	84aa                	mv	s1,a0
  if(pagetable == 0)
    80001a86:	c121                	beqz	a0,80001ac6 <proc_pagetable+0x58>
  if(mappages(pagetable, TRAMPOLINE, PGSIZE,
    80001a88:	4729                	li	a4,10
    80001a8a:	00005697          	auipc	a3,0x5
    80001a8e:	57668693          	addi	a3,a3,1398 # 80007000 <_trampoline>
    80001a92:	6605                	lui	a2,0x1
    80001a94:	040005b7          	lui	a1,0x4000
    80001a98:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    80001a9a:	05b2                	slli	a1,a1,0xc
    80001a9c:	fffff097          	auipc	ra,0xfffff
    80001aa0:	5f2080e7          	jalr	1522(ra) # 8000108e <mappages>
    80001aa4:	02054863          	bltz	a0,80001ad4 <proc_pagetable+0x66>
  if(mappages(pagetable, TRAPFRAME, PGSIZE,
    80001aa8:	4719                	li	a4,6
    80001aaa:	05893683          	ld	a3,88(s2)
    80001aae:	6605                	lui	a2,0x1
    80001ab0:	020005b7          	lui	a1,0x2000
    80001ab4:	15fd                	addi	a1,a1,-1 # 1ffffff <_entry-0x7e000001>
    80001ab6:	05b6                	slli	a1,a1,0xd
    80001ab8:	8526                	mv	a0,s1
    80001aba:	fffff097          	auipc	ra,0xfffff
    80001abe:	5d4080e7          	jalr	1492(ra) # 8000108e <mappages>
    80001ac2:	02054163          	bltz	a0,80001ae4 <proc_pagetable+0x76>
}
    80001ac6:	8526                	mv	a0,s1
    80001ac8:	60e2                	ld	ra,24(sp)
    80001aca:	6442                	ld	s0,16(sp)
    80001acc:	64a2                	ld	s1,8(sp)
    80001ace:	6902                	ld	s2,0(sp)
    80001ad0:	6105                	addi	sp,sp,32
    80001ad2:	8082                	ret
    uvmfree(pagetable, 0);
    80001ad4:	4581                	li	a1,0
    80001ad6:	8526                	mv	a0,s1
    80001ad8:	00000097          	auipc	ra,0x0
    80001adc:	a2c080e7          	jalr	-1492(ra) # 80001504 <uvmfree>
    return 0;
    80001ae0:	4481                	li	s1,0
    80001ae2:	b7d5                	j	80001ac6 <proc_pagetable+0x58>
    uvmunmap(pagetable, TRAMPOLINE, 1, 0);
    80001ae4:	4681                	li	a3,0
    80001ae6:	4605                	li	a2,1
    80001ae8:	040005b7          	lui	a1,0x4000
    80001aec:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    80001aee:	05b2                	slli	a1,a1,0xc
    80001af0:	8526                	mv	a0,s1
    80001af2:	fffff097          	auipc	ra,0xfffff
    80001af6:	750080e7          	jalr	1872(ra) # 80001242 <uvmunmap>
    uvmfree(pagetable, 0);
    80001afa:	4581                	li	a1,0
    80001afc:	8526                	mv	a0,s1
    80001afe:	00000097          	auipc	ra,0x0
    80001b02:	a06080e7          	jalr	-1530(ra) # 80001504 <uvmfree>
    return 0;
    80001b06:	4481                	li	s1,0
    80001b08:	bf7d                	j	80001ac6 <proc_pagetable+0x58>

0000000080001b0a <proc_freepagetable>:
{
    80001b0a:	1101                	addi	sp,sp,-32
    80001b0c:	ec06                	sd	ra,24(sp)
    80001b0e:	e822                	sd	s0,16(sp)
    80001b10:	e426                	sd	s1,8(sp)
    80001b12:	e04a                	sd	s2,0(sp)
    80001b14:	1000                	addi	s0,sp,32
    80001b16:	84aa                	mv	s1,a0
    80001b18:	892e                	mv	s2,a1
  uvmunmap(pagetable, TRAMPOLINE, 1, 0);
    80001b1a:	4681                	li	a3,0
    80001b1c:	4605                	li	a2,1
    80001b1e:	040005b7          	lui	a1,0x4000
    80001b22:	15fd                	addi	a1,a1,-1 # 3ffffff <_entry-0x7c000001>
    80001b24:	05b2                	slli	a1,a1,0xc
    80001b26:	fffff097          	auipc	ra,0xfffff
    80001b2a:	71c080e7          	jalr	1820(ra) # 80001242 <uvmunmap>
  uvmunmap(pagetable, TRAPFRAME, 1, 0);
    80001b2e:	4681                	li	a3,0
    80001b30:	4605                	li	a2,1
    80001b32:	020005b7          	lui	a1,0x2000
    80001b36:	15fd                	addi	a1,a1,-1 # 1ffffff <_entry-0x7e000001>
    80001b38:	05b6                	slli	a1,a1,0xd
    80001b3a:	8526                	mv	a0,s1
    80001b3c:	fffff097          	auipc	ra,0xfffff
    80001b40:	706080e7          	jalr	1798(ra) # 80001242 <uvmunmap>
  uvmfree(pagetable, sz);
    80001b44:	85ca                	mv	a1,s2
    80001b46:	8526                	mv	a0,s1
    80001b48:	00000097          	auipc	ra,0x0
    80001b4c:	9bc080e7          	jalr	-1604(ra) # 80001504 <uvmfree>
}
    80001b50:	60e2                	ld	ra,24(sp)
    80001b52:	6442                	ld	s0,16(sp)
    80001b54:	64a2                	ld	s1,8(sp)
    80001b56:	6902                	ld	s2,0(sp)
    80001b58:	6105                	addi	sp,sp,32
    80001b5a:	8082                	ret

0000000080001b5c <freeproc>:
{
    80001b5c:	1101                	addi	sp,sp,-32
    80001b5e:	ec06                	sd	ra,24(sp)
    80001b60:	e822                	sd	s0,16(sp)
    80001b62:	e426                	sd	s1,8(sp)
    80001b64:	1000                	addi	s0,sp,32
    80001b66:	84aa                	mv	s1,a0
  if(p->trapframe)
    80001b68:	6d28                	ld	a0,88(a0)
    80001b6a:	c509                	beqz	a0,80001b74 <freeproc+0x18>
    kfree((void*)p->trapframe);
    80001b6c:	fffff097          	auipc	ra,0xfffff
    80001b70:	e68080e7          	jalr	-408(ra) # 800009d4 <kfree>
  p->trapframe = 0;
    80001b74:	0404bc23          	sd	zero,88(s1)
  if(p->pagetable)
    80001b78:	68a8                	ld	a0,80(s1)
    80001b7a:	c511                	beqz	a0,80001b86 <freeproc+0x2a>
    proc_freepagetable(p->pagetable, p->sz);
    80001b7c:	64ac                	ld	a1,72(s1)
    80001b7e:	00000097          	auipc	ra,0x0
    80001b82:	f8c080e7          	jalr	-116(ra) # 80001b0a <proc_freepagetable>
  p->pagetable = 0;
    80001b86:	0404b823          	sd	zero,80(s1)
  p->sz = 0;
    80001b8a:	0404b423          	sd	zero,72(s1)
  p->pid = 0;
    80001b8e:	0204ac23          	sw	zero,56(s1)
  p->parent = 0;
    80001b92:	0204b023          	sd	zero,32(s1)
  p->name[0] = 0;
    80001b96:	14048c23          	sb	zero,344(s1)
  p->chan = 0;
    80001b9a:	0204b423          	sd	zero,40(s1)
  p->killed = 0;
    80001b9e:	0204a823          	sw	zero,48(s1)
  p->xstate = 0;
    80001ba2:	0204aa23          	sw	zero,52(s1)
  p->state = UNUSED;
    80001ba6:	0004ac23          	sw	zero,24(s1)
}
    80001baa:	60e2                	ld	ra,24(sp)
    80001bac:	6442                	ld	s0,16(sp)
    80001bae:	64a2                	ld	s1,8(sp)
    80001bb0:	6105                	addi	sp,sp,32
    80001bb2:	8082                	ret

0000000080001bb4 <allocproc>:
{
    80001bb4:	1101                	addi	sp,sp,-32
    80001bb6:	ec06                	sd	ra,24(sp)
    80001bb8:	e822                	sd	s0,16(sp)
    80001bba:	e426                	sd	s1,8(sp)
    80001bbc:	e04a                	sd	s2,0(sp)
    80001bbe:	1000                	addi	s0,sp,32
  for(p = proc; p < &proc[NPROC]; p++) {
    80001bc0:	00010497          	auipc	s1,0x10
    80001bc4:	af848493          	addi	s1,s1,-1288 # 800116b8 <proc>
    80001bc8:	00011917          	auipc	s2,0x11
    80001bcc:	90090913          	addi	s2,s2,-1792 # 800124c8 <tickslock>
    acquire(&p->lock);
    80001bd0:	8526                	mv	a0,s1
    80001bd2:	fffff097          	auipc	ra,0xfffff
    80001bd6:	ff0080e7          	jalr	-16(ra) # 80000bc2 <acquire>
    if(p->state == UNUSED) {
    80001bda:	4c9c                	lw	a5,24(s1)
    80001bdc:	c395                	beqz	a5,80001c00 <allocproc+0x4c>
      release(&p->lock);
    80001bde:	8526                	mv	a0,s1
    80001be0:	fffff097          	auipc	ra,0xfffff
    80001be4:	096080e7          	jalr	150(ra) # 80000c76 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80001be8:	16848493          	addi	s1,s1,360
    80001bec:	ff2492e3          	bne	s1,s2,80001bd0 <allocproc+0x1c>
  return 0;
    80001bf0:	4481                	li	s1,0
}
    80001bf2:	8526                	mv	a0,s1
    80001bf4:	60e2                	ld	ra,24(sp)
    80001bf6:	6442                	ld	s0,16(sp)
    80001bf8:	64a2                	ld	s1,8(sp)
    80001bfa:	6902                	ld	s2,0(sp)
    80001bfc:	6105                	addi	sp,sp,32
    80001bfe:	8082                	ret
  p->pid = allocpid();
    80001c00:	00000097          	auipc	ra,0x0
    80001c04:	e28080e7          	jalr	-472(ra) # 80001a28 <allocpid>
    80001c08:	dc88                	sw	a0,56(s1)
  if((p->trapframe = (struct trapframe *)kalloc()) == 0){
    80001c0a:	fffff097          	auipc	ra,0xfffff
    80001c0e:	ec8080e7          	jalr	-312(ra) # 80000ad2 <kalloc>
    80001c12:	892a                	mv	s2,a0
    80001c14:	eca8                	sd	a0,88(s1)
    80001c16:	cd05                	beqz	a0,80001c4e <allocproc+0x9a>
  p->pagetable = proc_pagetable(p);
    80001c18:	8526                	mv	a0,s1
    80001c1a:	00000097          	auipc	ra,0x0
    80001c1e:	e54080e7          	jalr	-428(ra) # 80001a6e <proc_pagetable>
    80001c22:	892a                	mv	s2,a0
    80001c24:	e8a8                	sd	a0,80(s1)
  if(p->pagetable == 0){
    80001c26:	c91d                	beqz	a0,80001c5c <allocproc+0xa8>
  memset(&p->context, 0, sizeof(p->context));
    80001c28:	07000613          	li	a2,112
    80001c2c:	4581                	li	a1,0
    80001c2e:	06048513          	addi	a0,s1,96
    80001c32:	fffff097          	auipc	ra,0xfffff
    80001c36:	08c080e7          	jalr	140(ra) # 80000cbe <memset>
  p->context.ra = (uint64)forkret;
    80001c3a:	00000797          	auipc	a5,0x0
    80001c3e:	da878793          	addi	a5,a5,-600 # 800019e2 <forkret>
    80001c42:	f0bc                	sd	a5,96(s1)
  p->context.sp = p->kstack + PGSIZE;
    80001c44:	60bc                	ld	a5,64(s1)
    80001c46:	6705                	lui	a4,0x1
    80001c48:	97ba                	add	a5,a5,a4
    80001c4a:	f4bc                	sd	a5,104(s1)
  return p;
    80001c4c:	b75d                	j	80001bf2 <allocproc+0x3e>
    release(&p->lock);
    80001c4e:	8526                	mv	a0,s1
    80001c50:	fffff097          	auipc	ra,0xfffff
    80001c54:	026080e7          	jalr	38(ra) # 80000c76 <release>
    return 0;
    80001c58:	84ca                	mv	s1,s2
    80001c5a:	bf61                	j	80001bf2 <allocproc+0x3e>
    freeproc(p);
    80001c5c:	8526                	mv	a0,s1
    80001c5e:	00000097          	auipc	ra,0x0
    80001c62:	efe080e7          	jalr	-258(ra) # 80001b5c <freeproc>
    release(&p->lock);
    80001c66:	8526                	mv	a0,s1
    80001c68:	fffff097          	auipc	ra,0xfffff
    80001c6c:	00e080e7          	jalr	14(ra) # 80000c76 <release>
    return 0;
    80001c70:	84ca                	mv	s1,s2
    80001c72:	b741                	j	80001bf2 <allocproc+0x3e>

0000000080001c74 <userinit>:
{
    80001c74:	1101                	addi	sp,sp,-32
    80001c76:	ec06                	sd	ra,24(sp)
    80001c78:	e822                	sd	s0,16(sp)
    80001c7a:	e426                	sd	s1,8(sp)
    80001c7c:	1000                	addi	s0,sp,32
  p = allocproc();
    80001c7e:	00000097          	auipc	ra,0x0
    80001c82:	f36080e7          	jalr	-202(ra) # 80001bb4 <allocproc>
    80001c86:	84aa                	mv	s1,a0
  initproc = p;
    80001c88:	00007797          	auipc	a5,0x7
    80001c8c:	3aa7b023          	sd	a0,928(a5) # 80009028 <initproc>
  uvminit(p->pagetable, initcode, sizeof(initcode));
    80001c90:	03400613          	li	a2,52
    80001c94:	00007597          	auipc	a1,0x7
    80001c98:	b3c58593          	addi	a1,a1,-1220 # 800087d0 <initcode>
    80001c9c:	6928                	ld	a0,80(a0)
    80001c9e:	fffff097          	auipc	ra,0xfffff
    80001ca2:	696080e7          	jalr	1686(ra) # 80001334 <uvminit>
  p->sz = PGSIZE;
    80001ca6:	6785                	lui	a5,0x1
    80001ca8:	e4bc                	sd	a5,72(s1)
  p->trapframe->epc = 0;      // user program counter
    80001caa:	6cb8                	ld	a4,88(s1)
    80001cac:	00073c23          	sd	zero,24(a4) # 1018 <_entry-0x7fffefe8>
  p->trapframe->sp = PGSIZE;  // user stack pointer
    80001cb0:	6cb8                	ld	a4,88(s1)
    80001cb2:	fb1c                	sd	a5,48(a4)
  safestrcpy(p->name, "initcode", sizeof(p->name));
    80001cb4:	4641                	li	a2,16
    80001cb6:	00006597          	auipc	a1,0x6
    80001cba:	52a58593          	addi	a1,a1,1322 # 800081e0 <digits+0x1a0>
    80001cbe:	15848513          	addi	a0,s1,344
    80001cc2:	fffff097          	auipc	ra,0xfffff
    80001cc6:	14e080e7          	jalr	334(ra) # 80000e10 <safestrcpy>
  p->cwd = namei("/");
    80001cca:	00006517          	auipc	a0,0x6
    80001cce:	52650513          	addi	a0,a0,1318 # 800081f0 <digits+0x1b0>
    80001cd2:	00003097          	auipc	ra,0x3
    80001cd6:	9a6080e7          	jalr	-1626(ra) # 80004678 <namei>
    80001cda:	14a4b823          	sd	a0,336(s1)
  p->state = RUNNABLE;
    80001cde:	4789                	li	a5,2
    80001ce0:	cc9c                	sw	a5,24(s1)
  release(&p->lock);
    80001ce2:	8526                	mv	a0,s1
    80001ce4:	fffff097          	auipc	ra,0xfffff
    80001ce8:	f92080e7          	jalr	-110(ra) # 80000c76 <release>
}
    80001cec:	60e2                	ld	ra,24(sp)
    80001cee:	6442                	ld	s0,16(sp)
    80001cf0:	64a2                	ld	s1,8(sp)
    80001cf2:	6105                	addi	sp,sp,32
    80001cf4:	8082                	ret

0000000080001cf6 <growproc>:
{
    80001cf6:	1101                	addi	sp,sp,-32
    80001cf8:	ec06                	sd	ra,24(sp)
    80001cfa:	e822                	sd	s0,16(sp)
    80001cfc:	e426                	sd	s1,8(sp)
    80001cfe:	e04a                	sd	s2,0(sp)
    80001d00:	1000                	addi	s0,sp,32
    80001d02:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80001d04:	00000097          	auipc	ra,0x0
    80001d08:	ca6080e7          	jalr	-858(ra) # 800019aa <myproc>
    80001d0c:	892a                	mv	s2,a0
  sz = p->sz;
    80001d0e:	652c                	ld	a1,72(a0)
    80001d10:	0005879b          	sext.w	a5,a1
  if(n > 0){
    80001d14:	00904f63          	bgtz	s1,80001d32 <growproc+0x3c>
  } else if(n < 0){
    80001d18:	0204cd63          	bltz	s1,80001d52 <growproc+0x5c>
  p->sz = sz;
    80001d1c:	1782                	slli	a5,a5,0x20
    80001d1e:	9381                	srli	a5,a5,0x20
    80001d20:	04f93423          	sd	a5,72(s2)
  return 0;
    80001d24:	4501                	li	a0,0
}
    80001d26:	60e2                	ld	ra,24(sp)
    80001d28:	6442                	ld	s0,16(sp)
    80001d2a:	64a2                	ld	s1,8(sp)
    80001d2c:	6902                	ld	s2,0(sp)
    80001d2e:	6105                	addi	sp,sp,32
    80001d30:	8082                	ret
    if((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0) {
    80001d32:	00f4863b          	addw	a2,s1,a5
    80001d36:	1602                	slli	a2,a2,0x20
    80001d38:	9201                	srli	a2,a2,0x20
    80001d3a:	1582                	slli	a1,a1,0x20
    80001d3c:	9181                	srli	a1,a1,0x20
    80001d3e:	6928                	ld	a0,80(a0)
    80001d40:	fffff097          	auipc	ra,0xfffff
    80001d44:	6ae080e7          	jalr	1710(ra) # 800013ee <uvmalloc>
    80001d48:	0005079b          	sext.w	a5,a0
    80001d4c:	fbe1                	bnez	a5,80001d1c <growproc+0x26>
      return -1;
    80001d4e:	557d                	li	a0,-1
    80001d50:	bfd9                	j	80001d26 <growproc+0x30>
    sz = uvmdealloc(p->pagetable, sz, sz + n);
    80001d52:	00f4863b          	addw	a2,s1,a5
    80001d56:	1602                	slli	a2,a2,0x20
    80001d58:	9201                	srli	a2,a2,0x20
    80001d5a:	1582                	slli	a1,a1,0x20
    80001d5c:	9181                	srli	a1,a1,0x20
    80001d5e:	6928                	ld	a0,80(a0)
    80001d60:	fffff097          	auipc	ra,0xfffff
    80001d64:	646080e7          	jalr	1606(ra) # 800013a6 <uvmdealloc>
    80001d68:	0005079b          	sext.w	a5,a0
    80001d6c:	bf45                	j	80001d1c <growproc+0x26>

0000000080001d6e <fork>:
{
    80001d6e:	7139                	addi	sp,sp,-64
    80001d70:	fc06                	sd	ra,56(sp)
    80001d72:	f822                	sd	s0,48(sp)
    80001d74:	f426                	sd	s1,40(sp)
    80001d76:	f04a                	sd	s2,32(sp)
    80001d78:	ec4e                	sd	s3,24(sp)
    80001d7a:	e852                	sd	s4,16(sp)
    80001d7c:	e456                	sd	s5,8(sp)
    80001d7e:	0080                	addi	s0,sp,64
  struct proc *p = myproc();
    80001d80:	00000097          	auipc	ra,0x0
    80001d84:	c2a080e7          	jalr	-982(ra) # 800019aa <myproc>
    80001d88:	8aaa                	mv	s5,a0
  if((np = allocproc()) == 0){
    80001d8a:	00000097          	auipc	ra,0x0
    80001d8e:	e2a080e7          	jalr	-470(ra) # 80001bb4 <allocproc>
    80001d92:	c17d                	beqz	a0,80001e78 <fork+0x10a>
    80001d94:	8a2a                	mv	s4,a0
  if(uvmcopy(p->pagetable, np->pagetable, p->sz) < 0){
    80001d96:	048ab603          	ld	a2,72(s5)
    80001d9a:	692c                	ld	a1,80(a0)
    80001d9c:	050ab503          	ld	a0,80(s5)
    80001da0:	fffff097          	auipc	ra,0xfffff
    80001da4:	79e080e7          	jalr	1950(ra) # 8000153e <uvmcopy>
    80001da8:	04054a63          	bltz	a0,80001dfc <fork+0x8e>
  np->sz = p->sz;
    80001dac:	048ab783          	ld	a5,72(s5)
    80001db0:	04fa3423          	sd	a5,72(s4)
  np->parent = p;
    80001db4:	035a3023          	sd	s5,32(s4)
  *(np->trapframe) = *(p->trapframe);
    80001db8:	058ab683          	ld	a3,88(s5)
    80001dbc:	87b6                	mv	a5,a3
    80001dbe:	058a3703          	ld	a4,88(s4)
    80001dc2:	12068693          	addi	a3,a3,288
    80001dc6:	0007b803          	ld	a6,0(a5) # 1000 <_entry-0x7ffff000>
    80001dca:	6788                	ld	a0,8(a5)
    80001dcc:	6b8c                	ld	a1,16(a5)
    80001dce:	6f90                	ld	a2,24(a5)
    80001dd0:	01073023          	sd	a6,0(a4)
    80001dd4:	e708                	sd	a0,8(a4)
    80001dd6:	eb0c                	sd	a1,16(a4)
    80001dd8:	ef10                	sd	a2,24(a4)
    80001dda:	02078793          	addi	a5,a5,32
    80001dde:	02070713          	addi	a4,a4,32
    80001de2:	fed792e3          	bne	a5,a3,80001dc6 <fork+0x58>
  np->trapframe->a0 = 0;
    80001de6:	058a3783          	ld	a5,88(s4)
    80001dea:	0607b823          	sd	zero,112(a5)
  for(i = 0; i < NOFILE; i++)
    80001dee:	0d0a8493          	addi	s1,s5,208
    80001df2:	0d0a0913          	addi	s2,s4,208
    80001df6:	150a8993          	addi	s3,s5,336
    80001dfa:	a00d                	j	80001e1c <fork+0xae>
    freeproc(np);
    80001dfc:	8552                	mv	a0,s4
    80001dfe:	00000097          	auipc	ra,0x0
    80001e02:	d5e080e7          	jalr	-674(ra) # 80001b5c <freeproc>
    release(&np->lock);
    80001e06:	8552                	mv	a0,s4
    80001e08:	fffff097          	auipc	ra,0xfffff
    80001e0c:	e6e080e7          	jalr	-402(ra) # 80000c76 <release>
    return -1;
    80001e10:	54fd                	li	s1,-1
    80001e12:	a889                	j	80001e64 <fork+0xf6>
  for(i = 0; i < NOFILE; i++)
    80001e14:	04a1                	addi	s1,s1,8
    80001e16:	0921                	addi	s2,s2,8
    80001e18:	01348b63          	beq	s1,s3,80001e2e <fork+0xc0>
    if(p->ofile[i])
    80001e1c:	6088                	ld	a0,0(s1)
    80001e1e:	d97d                	beqz	a0,80001e14 <fork+0xa6>
      np->ofile[i] = filedup(p->ofile[i]);
    80001e20:	00003097          	auipc	ra,0x3
    80001e24:	ef6080e7          	jalr	-266(ra) # 80004d16 <filedup>
    80001e28:	00a93023          	sd	a0,0(s2)
    80001e2c:	b7e5                	j	80001e14 <fork+0xa6>
  np->cwd = idup(p->cwd);
    80001e2e:	150ab503          	ld	a0,336(s5)
    80001e32:	00002097          	auipc	ra,0x2
    80001e36:	834080e7          	jalr	-1996(ra) # 80003666 <idup>
    80001e3a:	14aa3823          	sd	a0,336(s4)
  safestrcpy(np->name, p->name, sizeof(p->name));
    80001e3e:	4641                	li	a2,16
    80001e40:	158a8593          	addi	a1,s5,344
    80001e44:	158a0513          	addi	a0,s4,344
    80001e48:	fffff097          	auipc	ra,0xfffff
    80001e4c:	fc8080e7          	jalr	-56(ra) # 80000e10 <safestrcpy>
  pid = np->pid;
    80001e50:	038a2483          	lw	s1,56(s4)
  np->state = RUNNABLE;
    80001e54:	4789                	li	a5,2
    80001e56:	00fa2c23          	sw	a5,24(s4)
  release(&np->lock);
    80001e5a:	8552                	mv	a0,s4
    80001e5c:	fffff097          	auipc	ra,0xfffff
    80001e60:	e1a080e7          	jalr	-486(ra) # 80000c76 <release>
}
    80001e64:	8526                	mv	a0,s1
    80001e66:	70e2                	ld	ra,56(sp)
    80001e68:	7442                	ld	s0,48(sp)
    80001e6a:	74a2                	ld	s1,40(sp)
    80001e6c:	7902                	ld	s2,32(sp)
    80001e6e:	69e2                	ld	s3,24(sp)
    80001e70:	6a42                	ld	s4,16(sp)
    80001e72:	6aa2                	ld	s5,8(sp)
    80001e74:	6121                	addi	sp,sp,64
    80001e76:	8082                	ret
    return -1;
    80001e78:	54fd                	li	s1,-1
    80001e7a:	b7ed                	j	80001e64 <fork+0xf6>

0000000080001e7c <reparent>:
{
    80001e7c:	7179                	addi	sp,sp,-48
    80001e7e:	f406                	sd	ra,40(sp)
    80001e80:	f022                	sd	s0,32(sp)
    80001e82:	ec26                	sd	s1,24(sp)
    80001e84:	e84a                	sd	s2,16(sp)
    80001e86:	e44e                	sd	s3,8(sp)
    80001e88:	e052                	sd	s4,0(sp)
    80001e8a:	1800                	addi	s0,sp,48
    80001e8c:	892a                	mv	s2,a0
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001e8e:	00010497          	auipc	s1,0x10
    80001e92:	82a48493          	addi	s1,s1,-2006 # 800116b8 <proc>
      pp->parent = initproc;
    80001e96:	00007a17          	auipc	s4,0x7
    80001e9a:	192a0a13          	addi	s4,s4,402 # 80009028 <initproc>
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80001e9e:	00010997          	auipc	s3,0x10
    80001ea2:	62a98993          	addi	s3,s3,1578 # 800124c8 <tickslock>
    80001ea6:	a029                	j	80001eb0 <reparent+0x34>
    80001ea8:	16848493          	addi	s1,s1,360
    80001eac:	03348363          	beq	s1,s3,80001ed2 <reparent+0x56>
    if(pp->parent == p){
    80001eb0:	709c                	ld	a5,32(s1)
    80001eb2:	ff279be3          	bne	a5,s2,80001ea8 <reparent+0x2c>
      acquire(&pp->lock);
    80001eb6:	8526                	mv	a0,s1
    80001eb8:	fffff097          	auipc	ra,0xfffff
    80001ebc:	d0a080e7          	jalr	-758(ra) # 80000bc2 <acquire>
      pp->parent = initproc;
    80001ec0:	000a3783          	ld	a5,0(s4)
    80001ec4:	f09c                	sd	a5,32(s1)
      release(&pp->lock);
    80001ec6:	8526                	mv	a0,s1
    80001ec8:	fffff097          	auipc	ra,0xfffff
    80001ecc:	dae080e7          	jalr	-594(ra) # 80000c76 <release>
    80001ed0:	bfe1                	j	80001ea8 <reparent+0x2c>
}
    80001ed2:	70a2                	ld	ra,40(sp)
    80001ed4:	7402                	ld	s0,32(sp)
    80001ed6:	64e2                	ld	s1,24(sp)
    80001ed8:	6942                	ld	s2,16(sp)
    80001eda:	69a2                	ld	s3,8(sp)
    80001edc:	6a02                	ld	s4,0(sp)
    80001ede:	6145                	addi	sp,sp,48
    80001ee0:	8082                	ret

0000000080001ee2 <scheduler>:
{
    80001ee2:	711d                	addi	sp,sp,-96
    80001ee4:	ec86                	sd	ra,88(sp)
    80001ee6:	e8a2                	sd	s0,80(sp)
    80001ee8:	e4a6                	sd	s1,72(sp)
    80001eea:	e0ca                	sd	s2,64(sp)
    80001eec:	fc4e                	sd	s3,56(sp)
    80001eee:	f852                	sd	s4,48(sp)
    80001ef0:	f456                	sd	s5,40(sp)
    80001ef2:	f05a                	sd	s6,32(sp)
    80001ef4:	ec5e                	sd	s7,24(sp)
    80001ef6:	e862                	sd	s8,16(sp)
    80001ef8:	e466                	sd	s9,8(sp)
    80001efa:	1080                	addi	s0,sp,96
    80001efc:	8792                	mv	a5,tp
  int id = r_tp();
    80001efe:	2781                	sext.w	a5,a5
  c->proc = 0;
    80001f00:	00779b93          	slli	s7,a5,0x7
    80001f04:	0000f717          	auipc	a4,0xf
    80001f08:	39c70713          	addi	a4,a4,924 # 800112a0 <pid_lock>
    80001f0c:	975e                	add	a4,a4,s7
    80001f0e:	00073c23          	sd	zero,24(a4)
        swtch(&c->context, &p->context);
    80001f12:	0000f717          	auipc	a4,0xf
    80001f16:	3ae70713          	addi	a4,a4,942 # 800112c0 <cpus+0x8>
    80001f1a:	9bba                	add	s7,s7,a4
    int nproc = 0;
    80001f1c:	4c01                	li	s8,0
      if(p->state == RUNNABLE) {
    80001f1e:	4a89                	li	s5,2
        c->proc = p;
    80001f20:	079e                	slli	a5,a5,0x7
    80001f22:	0000fb17          	auipc	s6,0xf
    80001f26:	37eb0b13          	addi	s6,s6,894 # 800112a0 <pid_lock>
    80001f2a:	9b3e                	add	s6,s6,a5
    for(p = proc; p < &proc[NPROC]; p++) {
    80001f2c:	00010a17          	auipc	s4,0x10
    80001f30:	59ca0a13          	addi	s4,s4,1436 # 800124c8 <tickslock>
    80001f34:	a8a1                	j	80001f8c <scheduler+0xaa>
      release(&p->lock);
    80001f36:	8526                	mv	a0,s1
    80001f38:	fffff097          	auipc	ra,0xfffff
    80001f3c:	d3e080e7          	jalr	-706(ra) # 80000c76 <release>
    for(p = proc; p < &proc[NPROC]; p++) {
    80001f40:	16848493          	addi	s1,s1,360
    80001f44:	03448a63          	beq	s1,s4,80001f78 <scheduler+0x96>
      acquire(&p->lock);
    80001f48:	8526                	mv	a0,s1
    80001f4a:	fffff097          	auipc	ra,0xfffff
    80001f4e:	c78080e7          	jalr	-904(ra) # 80000bc2 <acquire>
      if(p->state != UNUSED) {
    80001f52:	4c9c                	lw	a5,24(s1)
    80001f54:	d3ed                	beqz	a5,80001f36 <scheduler+0x54>
        nproc++;
    80001f56:	2985                	addiw	s3,s3,1
      if(p->state == RUNNABLE) {
    80001f58:	fd579fe3          	bne	a5,s5,80001f36 <scheduler+0x54>
        p->state = RUNNING;
    80001f5c:	0194ac23          	sw	s9,24(s1)
        c->proc = p;
    80001f60:	009b3c23          	sd	s1,24(s6)
        swtch(&c->context, &p->context);
    80001f64:	06048593          	addi	a1,s1,96
    80001f68:	855e                	mv	a0,s7
    80001f6a:	00000097          	auipc	ra,0x0
    80001f6e:	60e080e7          	jalr	1550(ra) # 80002578 <swtch>
        c->proc = 0;
    80001f72:	000b3c23          	sd	zero,24(s6)
    80001f76:	b7c1                	j	80001f36 <scheduler+0x54>
    if(nproc <= 2) {   // only init and sh exist
    80001f78:	013aca63          	blt	s5,s3,80001f8c <scheduler+0xaa>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001f7c:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80001f80:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80001f84:	10079073          	csrw	sstatus,a5
      asm volatile("wfi");
    80001f88:	10500073          	wfi
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001f8c:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80001f90:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80001f94:	10079073          	csrw	sstatus,a5
    int nproc = 0;
    80001f98:	89e2                	mv	s3,s8
    for(p = proc; p < &proc[NPROC]; p++) {
    80001f9a:	0000f497          	auipc	s1,0xf
    80001f9e:	71e48493          	addi	s1,s1,1822 # 800116b8 <proc>
        p->state = RUNNING;
    80001fa2:	4c8d                	li	s9,3
    80001fa4:	b755                	j	80001f48 <scheduler+0x66>

0000000080001fa6 <sched>:
{
    80001fa6:	7179                	addi	sp,sp,-48
    80001fa8:	f406                	sd	ra,40(sp)
    80001faa:	f022                	sd	s0,32(sp)
    80001fac:	ec26                	sd	s1,24(sp)
    80001fae:	e84a                	sd	s2,16(sp)
    80001fb0:	e44e                	sd	s3,8(sp)
    80001fb2:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    80001fb4:	00000097          	auipc	ra,0x0
    80001fb8:	9f6080e7          	jalr	-1546(ra) # 800019aa <myproc>
    80001fbc:	84aa                	mv	s1,a0
  if(!holding(&p->lock))
    80001fbe:	fffff097          	auipc	ra,0xfffff
    80001fc2:	b8a080e7          	jalr	-1142(ra) # 80000b48 <holding>
    80001fc6:	c93d                	beqz	a0,8000203c <sched+0x96>
  asm volatile("mv %0, tp" : "=r" (x) );
    80001fc8:	8792                	mv	a5,tp
  if(mycpu()->noff != 1)
    80001fca:	2781                	sext.w	a5,a5
    80001fcc:	079e                	slli	a5,a5,0x7
    80001fce:	0000f717          	auipc	a4,0xf
    80001fd2:	2d270713          	addi	a4,a4,722 # 800112a0 <pid_lock>
    80001fd6:	97ba                	add	a5,a5,a4
    80001fd8:	0907a703          	lw	a4,144(a5)
    80001fdc:	4785                	li	a5,1
    80001fde:	06f71763          	bne	a4,a5,8000204c <sched+0xa6>
  if(p->state == RUNNING)
    80001fe2:	4c98                	lw	a4,24(s1)
    80001fe4:	478d                	li	a5,3
    80001fe6:	06f70b63          	beq	a4,a5,8000205c <sched+0xb6>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80001fea:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80001fee:	8b89                	andi	a5,a5,2
  if(intr_get())
    80001ff0:	efb5                	bnez	a5,8000206c <sched+0xc6>
  asm volatile("mv %0, tp" : "=r" (x) );
    80001ff2:	8792                	mv	a5,tp
  intena = mycpu()->intena;
    80001ff4:	0000f917          	auipc	s2,0xf
    80001ff8:	2ac90913          	addi	s2,s2,684 # 800112a0 <pid_lock>
    80001ffc:	2781                	sext.w	a5,a5
    80001ffe:	079e                	slli	a5,a5,0x7
    80002000:	97ca                	add	a5,a5,s2
    80002002:	0947a983          	lw	s3,148(a5)
    80002006:	8792                	mv	a5,tp
  swtch(&p->context, &mycpu()->context);
    80002008:	2781                	sext.w	a5,a5
    8000200a:	079e                	slli	a5,a5,0x7
    8000200c:	0000f597          	auipc	a1,0xf
    80002010:	2b458593          	addi	a1,a1,692 # 800112c0 <cpus+0x8>
    80002014:	95be                	add	a1,a1,a5
    80002016:	06048513          	addi	a0,s1,96
    8000201a:	00000097          	auipc	ra,0x0
    8000201e:	55e080e7          	jalr	1374(ra) # 80002578 <swtch>
    80002022:	8792                	mv	a5,tp
  mycpu()->intena = intena;
    80002024:	2781                	sext.w	a5,a5
    80002026:	079e                	slli	a5,a5,0x7
    80002028:	993e                	add	s2,s2,a5
    8000202a:	09392a23          	sw	s3,148(s2)
}
    8000202e:	70a2                	ld	ra,40(sp)
    80002030:	7402                	ld	s0,32(sp)
    80002032:	64e2                	ld	s1,24(sp)
    80002034:	6942                	ld	s2,16(sp)
    80002036:	69a2                	ld	s3,8(sp)
    80002038:	6145                	addi	sp,sp,48
    8000203a:	8082                	ret
    panic("sched p->lock");
    8000203c:	00006517          	auipc	a0,0x6
    80002040:	1bc50513          	addi	a0,a0,444 # 800081f8 <digits+0x1b8>
    80002044:	ffffe097          	auipc	ra,0xffffe
    80002048:	4e8080e7          	jalr	1256(ra) # 8000052c <panic>
    panic("sched locks");
    8000204c:	00006517          	auipc	a0,0x6
    80002050:	1bc50513          	addi	a0,a0,444 # 80008208 <digits+0x1c8>
    80002054:	ffffe097          	auipc	ra,0xffffe
    80002058:	4d8080e7          	jalr	1240(ra) # 8000052c <panic>
    panic("sched running");
    8000205c:	00006517          	auipc	a0,0x6
    80002060:	1bc50513          	addi	a0,a0,444 # 80008218 <digits+0x1d8>
    80002064:	ffffe097          	auipc	ra,0xffffe
    80002068:	4c8080e7          	jalr	1224(ra) # 8000052c <panic>
    panic("sched interruptible");
    8000206c:	00006517          	auipc	a0,0x6
    80002070:	1bc50513          	addi	a0,a0,444 # 80008228 <digits+0x1e8>
    80002074:	ffffe097          	auipc	ra,0xffffe
    80002078:	4b8080e7          	jalr	1208(ra) # 8000052c <panic>

000000008000207c <exit>:
{
    8000207c:	7179                	addi	sp,sp,-48
    8000207e:	f406                	sd	ra,40(sp)
    80002080:	f022                	sd	s0,32(sp)
    80002082:	ec26                	sd	s1,24(sp)
    80002084:	e84a                	sd	s2,16(sp)
    80002086:	e44e                	sd	s3,8(sp)
    80002088:	e052                	sd	s4,0(sp)
    8000208a:	1800                	addi	s0,sp,48
    8000208c:	8a2a                	mv	s4,a0
  struct proc *p = myproc();
    8000208e:	00000097          	auipc	ra,0x0
    80002092:	91c080e7          	jalr	-1764(ra) # 800019aa <myproc>
    80002096:	89aa                	mv	s3,a0
  if(p == initproc)
    80002098:	00007797          	auipc	a5,0x7
    8000209c:	f907b783          	ld	a5,-112(a5) # 80009028 <initproc>
    800020a0:	0d050493          	addi	s1,a0,208
    800020a4:	15050913          	addi	s2,a0,336
    800020a8:	02a79363          	bne	a5,a0,800020ce <exit+0x52>
    panic("init exiting");
    800020ac:	00006517          	auipc	a0,0x6
    800020b0:	19450513          	addi	a0,a0,404 # 80008240 <digits+0x200>
    800020b4:	ffffe097          	auipc	ra,0xffffe
    800020b8:	478080e7          	jalr	1144(ra) # 8000052c <panic>
      fileclose(f);
    800020bc:	00003097          	auipc	ra,0x3
    800020c0:	cac080e7          	jalr	-852(ra) # 80004d68 <fileclose>
      p->ofile[fd] = 0;
    800020c4:	0004b023          	sd	zero,0(s1)
  for(int fd = 0; fd < NOFILE; fd++){
    800020c8:	04a1                	addi	s1,s1,8
    800020ca:	01248563          	beq	s1,s2,800020d4 <exit+0x58>
    if(p->ofile[fd]){
    800020ce:	6088                	ld	a0,0(s1)
    800020d0:	f575                	bnez	a0,800020bc <exit+0x40>
    800020d2:	bfdd                	j	800020c8 <exit+0x4c>
  begin_op();
    800020d4:	00002097          	auipc	ra,0x2
    800020d8:	7c4080e7          	jalr	1988(ra) # 80004898 <begin_op>
  iput(p->cwd);
    800020dc:	1509b503          	ld	a0,336(s3)
    800020e0:	00002097          	auipc	ra,0x2
    800020e4:	824080e7          	jalr	-2012(ra) # 80003904 <iput>
  end_op();
    800020e8:	00003097          	auipc	ra,0x3
    800020ec:	82e080e7          	jalr	-2002(ra) # 80004916 <end_op>
  p->cwd = 0;
    800020f0:	1409b823          	sd	zero,336(s3)
  acquire(&initproc->lock);
    800020f4:	00007497          	auipc	s1,0x7
    800020f8:	f3448493          	addi	s1,s1,-204 # 80009028 <initproc>
    800020fc:	6088                	ld	a0,0(s1)
    800020fe:	fffff097          	auipc	ra,0xfffff
    80002102:	ac4080e7          	jalr	-1340(ra) # 80000bc2 <acquire>
  wakeup1(initproc);
    80002106:	6088                	ld	a0,0(s1)
    80002108:	fffff097          	auipc	ra,0xfffff
    8000210c:	704080e7          	jalr	1796(ra) # 8000180c <wakeup1>
  release(&initproc->lock);
    80002110:	6088                	ld	a0,0(s1)
    80002112:	fffff097          	auipc	ra,0xfffff
    80002116:	b64080e7          	jalr	-1180(ra) # 80000c76 <release>
  acquire(&p->lock);
    8000211a:	854e                	mv	a0,s3
    8000211c:	fffff097          	auipc	ra,0xfffff
    80002120:	aa6080e7          	jalr	-1370(ra) # 80000bc2 <acquire>
  struct proc *original_parent = p->parent;
    80002124:	0209b483          	ld	s1,32(s3)
  release(&p->lock);
    80002128:	854e                	mv	a0,s3
    8000212a:	fffff097          	auipc	ra,0xfffff
    8000212e:	b4c080e7          	jalr	-1204(ra) # 80000c76 <release>
  acquire(&original_parent->lock);
    80002132:	8526                	mv	a0,s1
    80002134:	fffff097          	auipc	ra,0xfffff
    80002138:	a8e080e7          	jalr	-1394(ra) # 80000bc2 <acquire>
  acquire(&p->lock);
    8000213c:	854e                	mv	a0,s3
    8000213e:	fffff097          	auipc	ra,0xfffff
    80002142:	a84080e7          	jalr	-1404(ra) # 80000bc2 <acquire>
  reparent(p);
    80002146:	854e                	mv	a0,s3
    80002148:	00000097          	auipc	ra,0x0
    8000214c:	d34080e7          	jalr	-716(ra) # 80001e7c <reparent>
  wakeup1(original_parent);
    80002150:	8526                	mv	a0,s1
    80002152:	fffff097          	auipc	ra,0xfffff
    80002156:	6ba080e7          	jalr	1722(ra) # 8000180c <wakeup1>
  p->xstate = status;
    8000215a:	0349aa23          	sw	s4,52(s3)
  p->state = ZOMBIE;
    8000215e:	4791                	li	a5,4
    80002160:	00f9ac23          	sw	a5,24(s3)
  release(&original_parent->lock);
    80002164:	8526                	mv	a0,s1
    80002166:	fffff097          	auipc	ra,0xfffff
    8000216a:	b10080e7          	jalr	-1264(ra) # 80000c76 <release>
  sched();
    8000216e:	00000097          	auipc	ra,0x0
    80002172:	e38080e7          	jalr	-456(ra) # 80001fa6 <sched>
  panic("zombie exit");
    80002176:	00006517          	auipc	a0,0x6
    8000217a:	0da50513          	addi	a0,a0,218 # 80008250 <digits+0x210>
    8000217e:	ffffe097          	auipc	ra,0xffffe
    80002182:	3ae080e7          	jalr	942(ra) # 8000052c <panic>

0000000080002186 <yield>:
{
    80002186:	1101                	addi	sp,sp,-32
    80002188:	ec06                	sd	ra,24(sp)
    8000218a:	e822                	sd	s0,16(sp)
    8000218c:	e426                	sd	s1,8(sp)
    8000218e:	1000                	addi	s0,sp,32
  struct proc *p = myproc();
    80002190:	00000097          	auipc	ra,0x0
    80002194:	81a080e7          	jalr	-2022(ra) # 800019aa <myproc>
    80002198:	84aa                	mv	s1,a0
  acquire(&p->lock);
    8000219a:	fffff097          	auipc	ra,0xfffff
    8000219e:	a28080e7          	jalr	-1496(ra) # 80000bc2 <acquire>
  p->state = RUNNABLE;
    800021a2:	4789                	li	a5,2
    800021a4:	cc9c                	sw	a5,24(s1)
  sched();
    800021a6:	00000097          	auipc	ra,0x0
    800021aa:	e00080e7          	jalr	-512(ra) # 80001fa6 <sched>
  release(&p->lock);
    800021ae:	8526                	mv	a0,s1
    800021b0:	fffff097          	auipc	ra,0xfffff
    800021b4:	ac6080e7          	jalr	-1338(ra) # 80000c76 <release>
}
    800021b8:	60e2                	ld	ra,24(sp)
    800021ba:	6442                	ld	s0,16(sp)
    800021bc:	64a2                	ld	s1,8(sp)
    800021be:	6105                	addi	sp,sp,32
    800021c0:	8082                	ret

00000000800021c2 <sleep>:
{
    800021c2:	7179                	addi	sp,sp,-48
    800021c4:	f406                	sd	ra,40(sp)
    800021c6:	f022                	sd	s0,32(sp)
    800021c8:	ec26                	sd	s1,24(sp)
    800021ca:	e84a                	sd	s2,16(sp)
    800021cc:	e44e                	sd	s3,8(sp)
    800021ce:	1800                	addi	s0,sp,48
    800021d0:	89aa                	mv	s3,a0
    800021d2:	892e                	mv	s2,a1
  struct proc *p = myproc();
    800021d4:	fffff097          	auipc	ra,0xfffff
    800021d8:	7d6080e7          	jalr	2006(ra) # 800019aa <myproc>
    800021dc:	84aa                	mv	s1,a0
  if(lk != &p->lock){  //DOC: sleeplock0
    800021de:	05250663          	beq	a0,s2,8000222a <sleep+0x68>
    acquire(&p->lock);  //DOC: sleeplock1
    800021e2:	fffff097          	auipc	ra,0xfffff
    800021e6:	9e0080e7          	jalr	-1568(ra) # 80000bc2 <acquire>
    release(lk);
    800021ea:	854a                	mv	a0,s2
    800021ec:	fffff097          	auipc	ra,0xfffff
    800021f0:	a8a080e7          	jalr	-1398(ra) # 80000c76 <release>
  p->chan = chan;
    800021f4:	0334b423          	sd	s3,40(s1)
  p->state = SLEEPING;
    800021f8:	4785                	li	a5,1
    800021fa:	cc9c                	sw	a5,24(s1)
  sched();
    800021fc:	00000097          	auipc	ra,0x0
    80002200:	daa080e7          	jalr	-598(ra) # 80001fa6 <sched>
  p->chan = 0;
    80002204:	0204b423          	sd	zero,40(s1)
    release(&p->lock);
    80002208:	8526                	mv	a0,s1
    8000220a:	fffff097          	auipc	ra,0xfffff
    8000220e:	a6c080e7          	jalr	-1428(ra) # 80000c76 <release>
    acquire(lk);
    80002212:	854a                	mv	a0,s2
    80002214:	fffff097          	auipc	ra,0xfffff
    80002218:	9ae080e7          	jalr	-1618(ra) # 80000bc2 <acquire>
}
    8000221c:	70a2                	ld	ra,40(sp)
    8000221e:	7402                	ld	s0,32(sp)
    80002220:	64e2                	ld	s1,24(sp)
    80002222:	6942                	ld	s2,16(sp)
    80002224:	69a2                	ld	s3,8(sp)
    80002226:	6145                	addi	sp,sp,48
    80002228:	8082                	ret
  p->chan = chan;
    8000222a:	03353423          	sd	s3,40(a0)
  p->state = SLEEPING;
    8000222e:	4785                	li	a5,1
    80002230:	cd1c                	sw	a5,24(a0)
  sched();
    80002232:	00000097          	auipc	ra,0x0
    80002236:	d74080e7          	jalr	-652(ra) # 80001fa6 <sched>
  p->chan = 0;
    8000223a:	0204b423          	sd	zero,40(s1)
  if(lk != &p->lock){
    8000223e:	bff9                	j	8000221c <sleep+0x5a>

0000000080002240 <wait>:
{
    80002240:	715d                	addi	sp,sp,-80
    80002242:	e486                	sd	ra,72(sp)
    80002244:	e0a2                	sd	s0,64(sp)
    80002246:	fc26                	sd	s1,56(sp)
    80002248:	f84a                	sd	s2,48(sp)
    8000224a:	f44e                	sd	s3,40(sp)
    8000224c:	f052                	sd	s4,32(sp)
    8000224e:	ec56                	sd	s5,24(sp)
    80002250:	e85a                	sd	s6,16(sp)
    80002252:	e45e                	sd	s7,8(sp)
    80002254:	0880                	addi	s0,sp,80
    80002256:	8aaa                	mv	s5,a0
  struct proc *p = myproc();
    80002258:	fffff097          	auipc	ra,0xfffff
    8000225c:	752080e7          	jalr	1874(ra) # 800019aa <myproc>
    80002260:	892a                	mv	s2,a0
  acquire(&p->lock);
    80002262:	fffff097          	auipc	ra,0xfffff
    80002266:	960080e7          	jalr	-1696(ra) # 80000bc2 <acquire>
    havekids = 0;
    8000226a:	4b81                	li	s7,0
        if(np->state == ZOMBIE){
    8000226c:	4a11                	li	s4,4
        havekids = 1;
    8000226e:	4b05                	li	s6,1
    for(np = proc; np < &proc[NPROC]; np++){
    80002270:	00010997          	auipc	s3,0x10
    80002274:	25898993          	addi	s3,s3,600 # 800124c8 <tickslock>
    havekids = 0;
    80002278:	875e                	mv	a4,s7
    for(np = proc; np < &proc[NPROC]; np++){
    8000227a:	0000f497          	auipc	s1,0xf
    8000227e:	43e48493          	addi	s1,s1,1086 # 800116b8 <proc>
    80002282:	a08d                	j	800022e4 <wait+0xa4>
          pid = np->pid;
    80002284:	0384a983          	lw	s3,56(s1)
          if(addr != 0 && copyout(p->pagetable, addr, (char *)&np->xstate,
    80002288:	000a8e63          	beqz	s5,800022a4 <wait+0x64>
    8000228c:	4691                	li	a3,4
    8000228e:	03448613          	addi	a2,s1,52
    80002292:	85d6                	mv	a1,s5
    80002294:	05093503          	ld	a0,80(s2)
    80002298:	fffff097          	auipc	ra,0xfffff
    8000229c:	3aa080e7          	jalr	938(ra) # 80001642 <copyout>
    800022a0:	02054263          	bltz	a0,800022c4 <wait+0x84>
          freeproc(np);
    800022a4:	8526                	mv	a0,s1
    800022a6:	00000097          	auipc	ra,0x0
    800022aa:	8b6080e7          	jalr	-1866(ra) # 80001b5c <freeproc>
          release(&np->lock);
    800022ae:	8526                	mv	a0,s1
    800022b0:	fffff097          	auipc	ra,0xfffff
    800022b4:	9c6080e7          	jalr	-1594(ra) # 80000c76 <release>
          release(&p->lock);
    800022b8:	854a                	mv	a0,s2
    800022ba:	fffff097          	auipc	ra,0xfffff
    800022be:	9bc080e7          	jalr	-1604(ra) # 80000c76 <release>
          return pid;
    800022c2:	a8a9                	j	8000231c <wait+0xdc>
            release(&np->lock);
    800022c4:	8526                	mv	a0,s1
    800022c6:	fffff097          	auipc	ra,0xfffff
    800022ca:	9b0080e7          	jalr	-1616(ra) # 80000c76 <release>
            release(&p->lock);
    800022ce:	854a                	mv	a0,s2
    800022d0:	fffff097          	auipc	ra,0xfffff
    800022d4:	9a6080e7          	jalr	-1626(ra) # 80000c76 <release>
            return -1;
    800022d8:	59fd                	li	s3,-1
    800022da:	a089                	j	8000231c <wait+0xdc>
    for(np = proc; np < &proc[NPROC]; np++){
    800022dc:	16848493          	addi	s1,s1,360
    800022e0:	03348463          	beq	s1,s3,80002308 <wait+0xc8>
      if(np->parent == p){
    800022e4:	709c                	ld	a5,32(s1)
    800022e6:	ff279be3          	bne	a5,s2,800022dc <wait+0x9c>
        acquire(&np->lock);
    800022ea:	8526                	mv	a0,s1
    800022ec:	fffff097          	auipc	ra,0xfffff
    800022f0:	8d6080e7          	jalr	-1834(ra) # 80000bc2 <acquire>
        if(np->state == ZOMBIE){
    800022f4:	4c9c                	lw	a5,24(s1)
    800022f6:	f94787e3          	beq	a5,s4,80002284 <wait+0x44>
        release(&np->lock);
    800022fa:	8526                	mv	a0,s1
    800022fc:	fffff097          	auipc	ra,0xfffff
    80002300:	97a080e7          	jalr	-1670(ra) # 80000c76 <release>
        havekids = 1;
    80002304:	875a                	mv	a4,s6
    80002306:	bfd9                	j	800022dc <wait+0x9c>
    if(!havekids || p->killed){
    80002308:	c701                	beqz	a4,80002310 <wait+0xd0>
    8000230a:	03092783          	lw	a5,48(s2)
    8000230e:	c39d                	beqz	a5,80002334 <wait+0xf4>
      release(&p->lock);
    80002310:	854a                	mv	a0,s2
    80002312:	fffff097          	auipc	ra,0xfffff
    80002316:	964080e7          	jalr	-1692(ra) # 80000c76 <release>
      return -1;
    8000231a:	59fd                	li	s3,-1
}
    8000231c:	854e                	mv	a0,s3
    8000231e:	60a6                	ld	ra,72(sp)
    80002320:	6406                	ld	s0,64(sp)
    80002322:	74e2                	ld	s1,56(sp)
    80002324:	7942                	ld	s2,48(sp)
    80002326:	79a2                	ld	s3,40(sp)
    80002328:	7a02                	ld	s4,32(sp)
    8000232a:	6ae2                	ld	s5,24(sp)
    8000232c:	6b42                	ld	s6,16(sp)
    8000232e:	6ba2                	ld	s7,8(sp)
    80002330:	6161                	addi	sp,sp,80
    80002332:	8082                	ret
    sleep(p, &p->lock);  //DOC: wait-sleep
    80002334:	85ca                	mv	a1,s2
    80002336:	854a                	mv	a0,s2
    80002338:	00000097          	auipc	ra,0x0
    8000233c:	e8a080e7          	jalr	-374(ra) # 800021c2 <sleep>
    havekids = 0;
    80002340:	bf25                	j	80002278 <wait+0x38>

0000000080002342 <wakeup>:
{
    80002342:	7139                	addi	sp,sp,-64
    80002344:	fc06                	sd	ra,56(sp)
    80002346:	f822                	sd	s0,48(sp)
    80002348:	f426                	sd	s1,40(sp)
    8000234a:	f04a                	sd	s2,32(sp)
    8000234c:	ec4e                	sd	s3,24(sp)
    8000234e:	e852                	sd	s4,16(sp)
    80002350:	e456                	sd	s5,8(sp)
    80002352:	0080                	addi	s0,sp,64
    80002354:	8a2a                	mv	s4,a0
  for(p = proc; p < &proc[NPROC]; p++) {
    80002356:	0000f497          	auipc	s1,0xf
    8000235a:	36248493          	addi	s1,s1,866 # 800116b8 <proc>
    if(p->state == SLEEPING && p->chan == chan) {
    8000235e:	4985                	li	s3,1
      p->state = RUNNABLE;
    80002360:	4a89                	li	s5,2
  for(p = proc; p < &proc[NPROC]; p++) {
    80002362:	00010917          	auipc	s2,0x10
    80002366:	16690913          	addi	s2,s2,358 # 800124c8 <tickslock>
    8000236a:	a811                	j	8000237e <wakeup+0x3c>
    release(&p->lock);
    8000236c:	8526                	mv	a0,s1
    8000236e:	fffff097          	auipc	ra,0xfffff
    80002372:	908080e7          	jalr	-1784(ra) # 80000c76 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80002376:	16848493          	addi	s1,s1,360
    8000237a:	03248063          	beq	s1,s2,8000239a <wakeup+0x58>
    acquire(&p->lock);
    8000237e:	8526                	mv	a0,s1
    80002380:	fffff097          	auipc	ra,0xfffff
    80002384:	842080e7          	jalr	-1982(ra) # 80000bc2 <acquire>
    if(p->state == SLEEPING && p->chan == chan) {
    80002388:	4c9c                	lw	a5,24(s1)
    8000238a:	ff3791e3          	bne	a5,s3,8000236c <wakeup+0x2a>
    8000238e:	749c                	ld	a5,40(s1)
    80002390:	fd479ee3          	bne	a5,s4,8000236c <wakeup+0x2a>
      p->state = RUNNABLE;
    80002394:	0154ac23          	sw	s5,24(s1)
    80002398:	bfd1                	j	8000236c <wakeup+0x2a>
}
    8000239a:	70e2                	ld	ra,56(sp)
    8000239c:	7442                	ld	s0,48(sp)
    8000239e:	74a2                	ld	s1,40(sp)
    800023a0:	7902                	ld	s2,32(sp)
    800023a2:	69e2                	ld	s3,24(sp)
    800023a4:	6a42                	ld	s4,16(sp)
    800023a6:	6aa2                	ld	s5,8(sp)
    800023a8:	6121                	addi	sp,sp,64
    800023aa:	8082                	ret

00000000800023ac <kill>:
// Kill the process with the given pid.
// The victim won't exit until it tries to return
// to user space (see usertrap() in trap.c).
int
kill(int pid)
{
    800023ac:	7179                	addi	sp,sp,-48
    800023ae:	f406                	sd	ra,40(sp)
    800023b0:	f022                	sd	s0,32(sp)
    800023b2:	ec26                	sd	s1,24(sp)
    800023b4:	e84a                	sd	s2,16(sp)
    800023b6:	e44e                	sd	s3,8(sp)
    800023b8:	1800                	addi	s0,sp,48
    800023ba:	892a                	mv	s2,a0
  struct proc *p;

  for(p = proc; p < &proc[NPROC]; p++){
    800023bc:	0000f497          	auipc	s1,0xf
    800023c0:	2fc48493          	addi	s1,s1,764 # 800116b8 <proc>
    800023c4:	00010997          	auipc	s3,0x10
    800023c8:	10498993          	addi	s3,s3,260 # 800124c8 <tickslock>
    acquire(&p->lock);
    800023cc:	8526                	mv	a0,s1
    800023ce:	ffffe097          	auipc	ra,0xffffe
    800023d2:	7f4080e7          	jalr	2036(ra) # 80000bc2 <acquire>
    if(p->pid == pid){
    800023d6:	5c9c                	lw	a5,56(s1)
    800023d8:	03278363          	beq	a5,s2,800023fe <kill+0x52>
        p->state = RUNNABLE;
      }
      release(&p->lock);
      return 0;
    }
    release(&p->lock);
    800023dc:	8526                	mv	a0,s1
    800023de:	fffff097          	auipc	ra,0xfffff
    800023e2:	898080e7          	jalr	-1896(ra) # 80000c76 <release>
  for(p = proc; p < &proc[NPROC]; p++){
    800023e6:	16848493          	addi	s1,s1,360
    800023ea:	ff3491e3          	bne	s1,s3,800023cc <kill+0x20>
  }
  return -1;
    800023ee:	557d                	li	a0,-1
}
    800023f0:	70a2                	ld	ra,40(sp)
    800023f2:	7402                	ld	s0,32(sp)
    800023f4:	64e2                	ld	s1,24(sp)
    800023f6:	6942                	ld	s2,16(sp)
    800023f8:	69a2                	ld	s3,8(sp)
    800023fa:	6145                	addi	sp,sp,48
    800023fc:	8082                	ret
      p->killed = 1;
    800023fe:	4785                	li	a5,1
    80002400:	d89c                	sw	a5,48(s1)
      if(p->state == SLEEPING){
    80002402:	4c98                	lw	a4,24(s1)
    80002404:	00f70963          	beq	a4,a5,80002416 <kill+0x6a>
      release(&p->lock);
    80002408:	8526                	mv	a0,s1
    8000240a:	fffff097          	auipc	ra,0xfffff
    8000240e:	86c080e7          	jalr	-1940(ra) # 80000c76 <release>
      return 0;
    80002412:	4501                	li	a0,0
    80002414:	bff1                	j	800023f0 <kill+0x44>
        p->state = RUNNABLE;
    80002416:	4789                	li	a5,2
    80002418:	cc9c                	sw	a5,24(s1)
    8000241a:	b7fd                	j	80002408 <kill+0x5c>

000000008000241c <either_copyout>:
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.
int
either_copyout(int user_dst, uint64 dst, void *src, uint64 len)
{
    8000241c:	7179                	addi	sp,sp,-48
    8000241e:	f406                	sd	ra,40(sp)
    80002420:	f022                	sd	s0,32(sp)
    80002422:	ec26                	sd	s1,24(sp)
    80002424:	e84a                	sd	s2,16(sp)
    80002426:	e44e                	sd	s3,8(sp)
    80002428:	e052                	sd	s4,0(sp)
    8000242a:	1800                	addi	s0,sp,48
    8000242c:	84aa                	mv	s1,a0
    8000242e:	892e                	mv	s2,a1
    80002430:	89b2                	mv	s3,a2
    80002432:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    80002434:	fffff097          	auipc	ra,0xfffff
    80002438:	576080e7          	jalr	1398(ra) # 800019aa <myproc>
  if(user_dst){
    8000243c:	c08d                	beqz	s1,8000245e <either_copyout+0x42>
    return copyout(p->pagetable, dst, src, len);
    8000243e:	86d2                	mv	a3,s4
    80002440:	864e                	mv	a2,s3
    80002442:	85ca                	mv	a1,s2
    80002444:	6928                	ld	a0,80(a0)
    80002446:	fffff097          	auipc	ra,0xfffff
    8000244a:	1fc080e7          	jalr	508(ra) # 80001642 <copyout>
  } else {
    memmove((char *)dst, src, len);
    return 0;
  }
}
    8000244e:	70a2                	ld	ra,40(sp)
    80002450:	7402                	ld	s0,32(sp)
    80002452:	64e2                	ld	s1,24(sp)
    80002454:	6942                	ld	s2,16(sp)
    80002456:	69a2                	ld	s3,8(sp)
    80002458:	6a02                	ld	s4,0(sp)
    8000245a:	6145                	addi	sp,sp,48
    8000245c:	8082                	ret
    memmove((char *)dst, src, len);
    8000245e:	000a061b          	sext.w	a2,s4
    80002462:	85ce                	mv	a1,s3
    80002464:	854a                	mv	a0,s2
    80002466:	fffff097          	auipc	ra,0xfffff
    8000246a:	8b4080e7          	jalr	-1868(ra) # 80000d1a <memmove>
    return 0;
    8000246e:	8526                	mv	a0,s1
    80002470:	bff9                	j	8000244e <either_copyout+0x32>

0000000080002472 <either_copyin>:
// Copy from either a user address, or kernel address,
// depending on usr_src.
// Returns 0 on success, -1 on error.
int
either_copyin(void *dst, int user_src, uint64 src, uint64 len)
{
    80002472:	7179                	addi	sp,sp,-48
    80002474:	f406                	sd	ra,40(sp)
    80002476:	f022                	sd	s0,32(sp)
    80002478:	ec26                	sd	s1,24(sp)
    8000247a:	e84a                	sd	s2,16(sp)
    8000247c:	e44e                	sd	s3,8(sp)
    8000247e:	e052                	sd	s4,0(sp)
    80002480:	1800                	addi	s0,sp,48
    80002482:	892a                	mv	s2,a0
    80002484:	84ae                	mv	s1,a1
    80002486:	89b2                	mv	s3,a2
    80002488:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    8000248a:	fffff097          	auipc	ra,0xfffff
    8000248e:	520080e7          	jalr	1312(ra) # 800019aa <myproc>
  if(user_src){
    80002492:	c08d                	beqz	s1,800024b4 <either_copyin+0x42>
    return copyin(p->pagetable, dst, src, len);
    80002494:	86d2                	mv	a3,s4
    80002496:	864e                	mv	a2,s3
    80002498:	85ca                	mv	a1,s2
    8000249a:	6928                	ld	a0,80(a0)
    8000249c:	fffff097          	auipc	ra,0xfffff
    800024a0:	232080e7          	jalr	562(ra) # 800016ce <copyin>
  } else {
    memmove(dst, (char*)src, len);
    return 0;
  }
}
    800024a4:	70a2                	ld	ra,40(sp)
    800024a6:	7402                	ld	s0,32(sp)
    800024a8:	64e2                	ld	s1,24(sp)
    800024aa:	6942                	ld	s2,16(sp)
    800024ac:	69a2                	ld	s3,8(sp)
    800024ae:	6a02                	ld	s4,0(sp)
    800024b0:	6145                	addi	sp,sp,48
    800024b2:	8082                	ret
    memmove(dst, (char*)src, len);
    800024b4:	000a061b          	sext.w	a2,s4
    800024b8:	85ce                	mv	a1,s3
    800024ba:	854a                	mv	a0,s2
    800024bc:	fffff097          	auipc	ra,0xfffff
    800024c0:	85e080e7          	jalr	-1954(ra) # 80000d1a <memmove>
    return 0;
    800024c4:	8526                	mv	a0,s1
    800024c6:	bff9                	j	800024a4 <either_copyin+0x32>

00000000800024c8 <procdump>:
// Print a process listing to console.  For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
{
    800024c8:	715d                	addi	sp,sp,-80
    800024ca:	e486                	sd	ra,72(sp)
    800024cc:	e0a2                	sd	s0,64(sp)
    800024ce:	fc26                	sd	s1,56(sp)
    800024d0:	f84a                	sd	s2,48(sp)
    800024d2:	f44e                	sd	s3,40(sp)
    800024d4:	f052                	sd	s4,32(sp)
    800024d6:	ec56                	sd	s5,24(sp)
    800024d8:	e85a                	sd	s6,16(sp)
    800024da:	e45e                	sd	s7,8(sp)
    800024dc:	0880                	addi	s0,sp,80
  [ZOMBIE]    "zombie"
  };
  struct proc *p;
  char *state;

  printf("\n");
    800024de:	00006517          	auipc	a0,0x6
    800024e2:	bea50513          	addi	a0,a0,-1046 # 800080c8 <digits+0x88>
    800024e6:	ffffe097          	auipc	ra,0xffffe
    800024ea:	090080e7          	jalr	144(ra) # 80000576 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    800024ee:	0000f497          	auipc	s1,0xf
    800024f2:	32248493          	addi	s1,s1,802 # 80011810 <proc+0x158>
    800024f6:	00010917          	auipc	s2,0x10
    800024fa:	12a90913          	addi	s2,s2,298 # 80012620 <bcache+0x140>
    if(p->state == UNUSED)
      continue;
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    800024fe:	4b11                	li	s6,4
      state = states[p->state];
    else
      state = "???";
    80002500:	00006997          	auipc	s3,0x6
    80002504:	d6098993          	addi	s3,s3,-672 # 80008260 <digits+0x220>
    printf("%d %s %s", p->pid, state, p->name);
    80002508:	00006a97          	auipc	s5,0x6
    8000250c:	d60a8a93          	addi	s5,s5,-672 # 80008268 <digits+0x228>
    printf("\n");
    80002510:	00006a17          	auipc	s4,0x6
    80002514:	bb8a0a13          	addi	s4,s4,-1096 # 800080c8 <digits+0x88>
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002518:	00006b97          	auipc	s7,0x6
    8000251c:	d88b8b93          	addi	s7,s7,-632 # 800082a0 <states.0>
    80002520:	a00d                	j	80002542 <procdump+0x7a>
    printf("%d %s %s", p->pid, state, p->name);
    80002522:	ee06a583          	lw	a1,-288(a3)
    80002526:	8556                	mv	a0,s5
    80002528:	ffffe097          	auipc	ra,0xffffe
    8000252c:	04e080e7          	jalr	78(ra) # 80000576 <printf>
    printf("\n");
    80002530:	8552                	mv	a0,s4
    80002532:	ffffe097          	auipc	ra,0xffffe
    80002536:	044080e7          	jalr	68(ra) # 80000576 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    8000253a:	16848493          	addi	s1,s1,360
    8000253e:	03248263          	beq	s1,s2,80002562 <procdump+0x9a>
    if(p->state == UNUSED)
    80002542:	86a6                	mv	a3,s1
    80002544:	ec04a783          	lw	a5,-320(s1)
    80002548:	dbed                	beqz	a5,8000253a <procdump+0x72>
      state = "???";
    8000254a:	864e                	mv	a2,s3
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    8000254c:	fcfb6be3          	bltu	s6,a5,80002522 <procdump+0x5a>
    80002550:	02079713          	slli	a4,a5,0x20
    80002554:	01d75793          	srli	a5,a4,0x1d
    80002558:	97de                	add	a5,a5,s7
    8000255a:	6390                	ld	a2,0(a5)
    8000255c:	f279                	bnez	a2,80002522 <procdump+0x5a>
      state = "???";
    8000255e:	864e                	mv	a2,s3
    80002560:	b7c9                	j	80002522 <procdump+0x5a>
  }
}
    80002562:	60a6                	ld	ra,72(sp)
    80002564:	6406                	ld	s0,64(sp)
    80002566:	74e2                	ld	s1,56(sp)
    80002568:	7942                	ld	s2,48(sp)
    8000256a:	79a2                	ld	s3,40(sp)
    8000256c:	7a02                	ld	s4,32(sp)
    8000256e:	6ae2                	ld	s5,24(sp)
    80002570:	6b42                	ld	s6,16(sp)
    80002572:	6ba2                	ld	s7,8(sp)
    80002574:	6161                	addi	sp,sp,80
    80002576:	8082                	ret

0000000080002578 <swtch>:
    80002578:	00153023          	sd	ra,0(a0)
    8000257c:	00253423          	sd	sp,8(a0)
    80002580:	e900                	sd	s0,16(a0)
    80002582:	ed04                	sd	s1,24(a0)
    80002584:	03253023          	sd	s2,32(a0)
    80002588:	03353423          	sd	s3,40(a0)
    8000258c:	03453823          	sd	s4,48(a0)
    80002590:	03553c23          	sd	s5,56(a0)
    80002594:	05653023          	sd	s6,64(a0)
    80002598:	05753423          	sd	s7,72(a0)
    8000259c:	05853823          	sd	s8,80(a0)
    800025a0:	05953c23          	sd	s9,88(a0)
    800025a4:	07a53023          	sd	s10,96(a0)
    800025a8:	07b53423          	sd	s11,104(a0)
    800025ac:	0005b083          	ld	ra,0(a1)
    800025b0:	0085b103          	ld	sp,8(a1)
    800025b4:	6980                	ld	s0,16(a1)
    800025b6:	6d84                	ld	s1,24(a1)
    800025b8:	0205b903          	ld	s2,32(a1)
    800025bc:	0285b983          	ld	s3,40(a1)
    800025c0:	0305ba03          	ld	s4,48(a1)
    800025c4:	0385ba83          	ld	s5,56(a1)
    800025c8:	0405bb03          	ld	s6,64(a1)
    800025cc:	0485bb83          	ld	s7,72(a1)
    800025d0:	0505bc03          	ld	s8,80(a1)
    800025d4:	0585bc83          	ld	s9,88(a1)
    800025d8:	0605bd03          	ld	s10,96(a1)
    800025dc:	0685bd83          	ld	s11,104(a1)
    800025e0:	8082                	ret

00000000800025e2 <trapinit>:

extern int devintr();

void
trapinit(void)
{
    800025e2:	1141                	addi	sp,sp,-16
    800025e4:	e406                	sd	ra,8(sp)
    800025e6:	e022                	sd	s0,0(sp)
    800025e8:	0800                	addi	s0,sp,16
  initlock(&tickslock, "time");
    800025ea:	00006597          	auipc	a1,0x6
    800025ee:	cde58593          	addi	a1,a1,-802 # 800082c8 <states.0+0x28>
    800025f2:	00010517          	auipc	a0,0x10
    800025f6:	ed650513          	addi	a0,a0,-298 # 800124c8 <tickslock>
    800025fa:	ffffe097          	auipc	ra,0xffffe
    800025fe:	538080e7          	jalr	1336(ra) # 80000b32 <initlock>
}
    80002602:	60a2                	ld	ra,8(sp)
    80002604:	6402                	ld	s0,0(sp)
    80002606:	0141                	addi	sp,sp,16
    80002608:	8082                	ret

000000008000260a <trapinithart>:

// set up to take exceptions and traps while in the kernel.
void
trapinithart(void)
{
    8000260a:	1141                	addi	sp,sp,-16
    8000260c:	e422                	sd	s0,8(sp)
    8000260e:	0800                	addi	s0,sp,16
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002610:	00004797          	auipc	a5,0x4
    80002614:	f4078793          	addi	a5,a5,-192 # 80006550 <kernelvec>
    80002618:	10579073          	csrw	stvec,a5
  w_stvec((uint64)kernelvec);
}
    8000261c:	6422                	ld	s0,8(sp)
    8000261e:	0141                	addi	sp,sp,16
    80002620:	8082                	ret

0000000080002622 <usertrapret>:
//
// return to user space
//
void
usertrapret(void)
{
    80002622:	1141                	addi	sp,sp,-16
    80002624:	e406                	sd	ra,8(sp)
    80002626:	e022                	sd	s0,0(sp)
    80002628:	0800                	addi	s0,sp,16
  struct proc *p = myproc();
    8000262a:	fffff097          	auipc	ra,0xfffff
    8000262e:	380080e7          	jalr	896(ra) # 800019aa <myproc>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002632:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    80002636:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002638:	10079073          	csrw	sstatus,a5
  // kerneltrap() to usertrap(), so turn off interrupts until
  // we're back in user space, where usertrap() is correct.
  intr_off();

  // send syscalls, interrupts, and exceptions to trampoline.S
  w_stvec(TRAMPOLINE + (uservec - trampoline));
    8000263c:	00005697          	auipc	a3,0x5
    80002640:	9c468693          	addi	a3,a3,-1596 # 80007000 <_trampoline>
    80002644:	00005717          	auipc	a4,0x5
    80002648:	9bc70713          	addi	a4,a4,-1604 # 80007000 <_trampoline>
    8000264c:	8f15                	sub	a4,a4,a3
    8000264e:	040007b7          	lui	a5,0x4000
    80002652:	17fd                	addi	a5,a5,-1 # 3ffffff <_entry-0x7c000001>
    80002654:	07b2                	slli	a5,a5,0xc
    80002656:	973e                	add	a4,a4,a5
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002658:	10571073          	csrw	stvec,a4

  // set up trapframe values that uservec will need when
  // the process next re-enters the kernel.
  p->trapframe->kernel_satp = r_satp();         // kernel page table
    8000265c:	6d38                	ld	a4,88(a0)
  asm volatile("csrr %0, satp" : "=r" (x) );
    8000265e:	18002673          	csrr	a2,satp
    80002662:	e310                	sd	a2,0(a4)
  p->trapframe->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
    80002664:	6d30                	ld	a2,88(a0)
    80002666:	6138                	ld	a4,64(a0)
    80002668:	6585                	lui	a1,0x1
    8000266a:	972e                	add	a4,a4,a1
    8000266c:	e618                	sd	a4,8(a2)
  p->trapframe->kernel_trap = (uint64)usertrap;
    8000266e:	6d38                	ld	a4,88(a0)
    80002670:	00000617          	auipc	a2,0x0
    80002674:	13860613          	addi	a2,a2,312 # 800027a8 <usertrap>
    80002678:	eb10                	sd	a2,16(a4)
  p->trapframe->kernel_hartid = r_tp();         // hartid for cpuid()
    8000267a:	6d38                	ld	a4,88(a0)
  asm volatile("mv %0, tp" : "=r" (x) );
    8000267c:	8612                	mv	a2,tp
    8000267e:	f310                	sd	a2,32(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002680:	10002773          	csrr	a4,sstatus
  // set up the registers that trampoline.S's sret will use
  // to get to user space.
  
  // set S Previous Privilege mode to User.
  unsigned long x = r_sstatus();
  x &= ~SSTATUS_SPP; // clear SPP to 0 for user mode
    80002684:	eff77713          	andi	a4,a4,-257
  x |= SSTATUS_SPIE; // enable interrupts in user mode
    80002688:	02076713          	ori	a4,a4,32
  asm volatile("csrw sstatus, %0" : : "r" (x));
    8000268c:	10071073          	csrw	sstatus,a4
  w_sstatus(x);

  // set S Exception Program Counter to the saved user pc.
  w_sepc(p->trapframe->epc);
    80002690:	6d38                	ld	a4,88(a0)
  asm volatile("csrw sepc, %0" : : "r" (x));
    80002692:	6f18                	ld	a4,24(a4)
    80002694:	14171073          	csrw	sepc,a4

  // tell trampoline.S the user page table to switch to.
  uint64 satp = MAKE_SATP(p->pagetable);
    80002698:	692c                	ld	a1,80(a0)
    8000269a:	81b1                	srli	a1,a1,0xc

  // jump to trampoline.S at the top of memory, which 
  // switches to the user page table, restores user registers,
  // and switches to user mode with sret.
  uint64 fn = TRAMPOLINE + (userret - trampoline);
    8000269c:	00005717          	auipc	a4,0x5
    800026a0:	9f470713          	addi	a4,a4,-1548 # 80007090 <userret>
    800026a4:	8f15                	sub	a4,a4,a3
    800026a6:	97ba                	add	a5,a5,a4
  ((void (*)(uint64,uint64))fn)(TRAPFRAME, satp);
    800026a8:	577d                	li	a4,-1
    800026aa:	177e                	slli	a4,a4,0x3f
    800026ac:	8dd9                	or	a1,a1,a4
    800026ae:	02000537          	lui	a0,0x2000
    800026b2:	157d                	addi	a0,a0,-1 # 1ffffff <_entry-0x7e000001>
    800026b4:	0536                	slli	a0,a0,0xd
    800026b6:	9782                	jalr	a5
}
    800026b8:	60a2                	ld	ra,8(sp)
    800026ba:	6402                	ld	s0,0(sp)
    800026bc:	0141                	addi	sp,sp,16
    800026be:	8082                	ret

00000000800026c0 <clockintr>:
  w_sstatus(sstatus);
}

void
clockintr()
{
    800026c0:	1101                	addi	sp,sp,-32
    800026c2:	ec06                	sd	ra,24(sp)
    800026c4:	e822                	sd	s0,16(sp)
    800026c6:	e426                	sd	s1,8(sp)
    800026c8:	1000                	addi	s0,sp,32
  acquire(&tickslock);
    800026ca:	00010497          	auipc	s1,0x10
    800026ce:	dfe48493          	addi	s1,s1,-514 # 800124c8 <tickslock>
    800026d2:	8526                	mv	a0,s1
    800026d4:	ffffe097          	auipc	ra,0xffffe
    800026d8:	4ee080e7          	jalr	1262(ra) # 80000bc2 <acquire>
  ticks++;
    800026dc:	00007517          	auipc	a0,0x7
    800026e0:	95450513          	addi	a0,a0,-1708 # 80009030 <ticks>
    800026e4:	411c                	lw	a5,0(a0)
    800026e6:	2785                	addiw	a5,a5,1
    800026e8:	c11c                	sw	a5,0(a0)
  wakeup(&ticks);
    800026ea:	00000097          	auipc	ra,0x0
    800026ee:	c58080e7          	jalr	-936(ra) # 80002342 <wakeup>
  release(&tickslock);
    800026f2:	8526                	mv	a0,s1
    800026f4:	ffffe097          	auipc	ra,0xffffe
    800026f8:	582080e7          	jalr	1410(ra) # 80000c76 <release>
}
    800026fc:	60e2                	ld	ra,24(sp)
    800026fe:	6442                	ld	s0,16(sp)
    80002700:	64a2                	ld	s1,8(sp)
    80002702:	6105                	addi	sp,sp,32
    80002704:	8082                	ret

0000000080002706 <devintr>:
// returns 2 if timer interrupt,
// 1 if other device,
// 0 if not recognized.
int
devintr()
{
    80002706:	1101                	addi	sp,sp,-32
    80002708:	ec06                	sd	ra,24(sp)
    8000270a:	e822                	sd	s0,16(sp)
    8000270c:	e426                	sd	s1,8(sp)
    8000270e:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002710:	14202773          	csrr	a4,scause
  uint64 scause = r_scause();

  if((scause & 0x8000000000000000L) &&
    80002714:	00074d63          	bltz	a4,8000272e <devintr+0x28>
    // now allowed to interrupt again.
    if(irq)
      plic_complete(irq);

    return 1;
  } else if(scause == 0x8000000000000001L){
    80002718:	57fd                	li	a5,-1
    8000271a:	17fe                	slli	a5,a5,0x3f
    8000271c:	0785                	addi	a5,a5,1
    // the SSIP bit in sip.
    w_sip(r_sip() & ~2);

    return 2;
  } else {
    return 0;
    8000271e:	4501                	li	a0,0
  } else if(scause == 0x8000000000000001L){
    80002720:	06f70363          	beq	a4,a5,80002786 <devintr+0x80>
  }
}
    80002724:	60e2                	ld	ra,24(sp)
    80002726:	6442                	ld	s0,16(sp)
    80002728:	64a2                	ld	s1,8(sp)
    8000272a:	6105                	addi	sp,sp,32
    8000272c:	8082                	ret
     (scause & 0xff) == 9){
    8000272e:	0ff77793          	zext.b	a5,a4
  if((scause & 0x8000000000000000L) &&
    80002732:	46a5                	li	a3,9
    80002734:	fed792e3          	bne	a5,a3,80002718 <devintr+0x12>
    int irq = plic_claim();
    80002738:	00004097          	auipc	ra,0x4
    8000273c:	f20080e7          	jalr	-224(ra) # 80006658 <plic_claim>
    80002740:	84aa                	mv	s1,a0
    if(irq == UART0_IRQ){
    80002742:	47a9                	li	a5,10
    80002744:	02f50763          	beq	a0,a5,80002772 <devintr+0x6c>
    } else if(irq == VIRTIO0_IRQ){
    80002748:	4785                	li	a5,1
    8000274a:	02f50963          	beq	a0,a5,8000277c <devintr+0x76>
    return 1;
    8000274e:	4505                	li	a0,1
    } else if(irq){
    80002750:	d8f1                	beqz	s1,80002724 <devintr+0x1e>
      printf("unexpected interrupt irq=%d\n", irq);
    80002752:	85a6                	mv	a1,s1
    80002754:	00006517          	auipc	a0,0x6
    80002758:	b7c50513          	addi	a0,a0,-1156 # 800082d0 <states.0+0x30>
    8000275c:	ffffe097          	auipc	ra,0xffffe
    80002760:	e1a080e7          	jalr	-486(ra) # 80000576 <printf>
      plic_complete(irq);
    80002764:	8526                	mv	a0,s1
    80002766:	00004097          	auipc	ra,0x4
    8000276a:	f16080e7          	jalr	-234(ra) # 8000667c <plic_complete>
    return 1;
    8000276e:	4505                	li	a0,1
    80002770:	bf55                	j	80002724 <devintr+0x1e>
      uartintr();
    80002772:	ffffe097          	auipc	ra,0xffffe
    80002776:	212080e7          	jalr	530(ra) # 80000984 <uartintr>
    8000277a:	b7ed                	j	80002764 <devintr+0x5e>
      virtio_disk_intr();
    8000277c:	00004097          	auipc	ra,0x4
    80002780:	38c080e7          	jalr	908(ra) # 80006b08 <virtio_disk_intr>
    80002784:	b7c5                	j	80002764 <devintr+0x5e>
    if(cpuid() == 0){
    80002786:	fffff097          	auipc	ra,0xfffff
    8000278a:	1f8080e7          	jalr	504(ra) # 8000197e <cpuid>
    8000278e:	c901                	beqz	a0,8000279e <devintr+0x98>
  asm volatile("csrr %0, sip" : "=r" (x) );
    80002790:	144027f3          	csrr	a5,sip
    w_sip(r_sip() & ~2);
    80002794:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sip, %0" : : "r" (x));
    80002796:	14479073          	csrw	sip,a5
    return 2;
    8000279a:	4509                	li	a0,2
    8000279c:	b761                	j	80002724 <devintr+0x1e>
      clockintr();
    8000279e:	00000097          	auipc	ra,0x0
    800027a2:	f22080e7          	jalr	-222(ra) # 800026c0 <clockintr>
    800027a6:	b7ed                	j	80002790 <devintr+0x8a>

00000000800027a8 <usertrap>:
{
    800027a8:	1101                	addi	sp,sp,-32
    800027aa:	ec06                	sd	ra,24(sp)
    800027ac:	e822                	sd	s0,16(sp)
    800027ae:	e426                	sd	s1,8(sp)
    800027b0:	e04a                	sd	s2,0(sp)
    800027b2:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800027b4:	100027f3          	csrr	a5,sstatus
  if((r_sstatus() & SSTATUS_SPP) != 0)
    800027b8:	1007f793          	andi	a5,a5,256
    800027bc:	e3ad                	bnez	a5,8000281e <usertrap+0x76>
  asm volatile("csrw stvec, %0" : : "r" (x));
    800027be:	00004797          	auipc	a5,0x4
    800027c2:	d9278793          	addi	a5,a5,-622 # 80006550 <kernelvec>
    800027c6:	10579073          	csrw	stvec,a5
  struct proc *p = myproc();
    800027ca:	fffff097          	auipc	ra,0xfffff
    800027ce:	1e0080e7          	jalr	480(ra) # 800019aa <myproc>
    800027d2:	84aa                	mv	s1,a0
  p->trapframe->epc = r_sepc();
    800027d4:	6d3c                	ld	a5,88(a0)
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800027d6:	14102773          	csrr	a4,sepc
    800027da:	ef98                	sd	a4,24(a5)
  asm volatile("csrr %0, scause" : "=r" (x) );
    800027dc:	14202773          	csrr	a4,scause
  if(r_scause() == 8){
    800027e0:	47a1                	li	a5,8
    800027e2:	04f71c63          	bne	a4,a5,8000283a <usertrap+0x92>
    if(p->killed)
    800027e6:	591c                	lw	a5,48(a0)
    800027e8:	e3b9                	bnez	a5,8000282e <usertrap+0x86>
    p->trapframe->epc += 4;
    800027ea:	6cb8                	ld	a4,88(s1)
    800027ec:	6f1c                	ld	a5,24(a4)
    800027ee:	0791                	addi	a5,a5,4
    800027f0:	ef1c                	sd	a5,24(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800027f2:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    800027f6:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800027fa:	10079073          	csrw	sstatus,a5
    syscall();
    800027fe:	00000097          	auipc	ra,0x0
    80002802:	2e0080e7          	jalr	736(ra) # 80002ade <syscall>
  if(p->killed)
    80002806:	589c                	lw	a5,48(s1)
    80002808:	ebc1                	bnez	a5,80002898 <usertrap+0xf0>
  usertrapret();
    8000280a:	00000097          	auipc	ra,0x0
    8000280e:	e18080e7          	jalr	-488(ra) # 80002622 <usertrapret>
}
    80002812:	60e2                	ld	ra,24(sp)
    80002814:	6442                	ld	s0,16(sp)
    80002816:	64a2                	ld	s1,8(sp)
    80002818:	6902                	ld	s2,0(sp)
    8000281a:	6105                	addi	sp,sp,32
    8000281c:	8082                	ret
    panic("usertrap: not from user mode");
    8000281e:	00006517          	auipc	a0,0x6
    80002822:	ad250513          	addi	a0,a0,-1326 # 800082f0 <states.0+0x50>
    80002826:	ffffe097          	auipc	ra,0xffffe
    8000282a:	d06080e7          	jalr	-762(ra) # 8000052c <panic>
      exit(-1);
    8000282e:	557d                	li	a0,-1
    80002830:	00000097          	auipc	ra,0x0
    80002834:	84c080e7          	jalr	-1972(ra) # 8000207c <exit>
    80002838:	bf4d                	j	800027ea <usertrap+0x42>
  } else if((which_dev = devintr()) != 0){
    8000283a:	00000097          	auipc	ra,0x0
    8000283e:	ecc080e7          	jalr	-308(ra) # 80002706 <devintr>
    80002842:	892a                	mv	s2,a0
    80002844:	c501                	beqz	a0,8000284c <usertrap+0xa4>
  if(p->killed)
    80002846:	589c                	lw	a5,48(s1)
    80002848:	c3a1                	beqz	a5,80002888 <usertrap+0xe0>
    8000284a:	a815                	j	8000287e <usertrap+0xd6>
  asm volatile("csrr %0, scause" : "=r" (x) );
    8000284c:	142025f3          	csrr	a1,scause
    printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
    80002850:	5c90                	lw	a2,56(s1)
    80002852:	00006517          	auipc	a0,0x6
    80002856:	abe50513          	addi	a0,a0,-1346 # 80008310 <states.0+0x70>
    8000285a:	ffffe097          	auipc	ra,0xffffe
    8000285e:	d1c080e7          	jalr	-740(ra) # 80000576 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002862:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002866:	14302673          	csrr	a2,stval
    printf("            sepc=%p stval=%p\n", r_sepc(), r_stval());
    8000286a:	00006517          	auipc	a0,0x6
    8000286e:	ad650513          	addi	a0,a0,-1322 # 80008340 <states.0+0xa0>
    80002872:	ffffe097          	auipc	ra,0xffffe
    80002876:	d04080e7          	jalr	-764(ra) # 80000576 <printf>
    p->killed = 1;
    8000287a:	4785                	li	a5,1
    8000287c:	d89c                	sw	a5,48(s1)
    exit(-1);
    8000287e:	557d                	li	a0,-1
    80002880:	fffff097          	auipc	ra,0xfffff
    80002884:	7fc080e7          	jalr	2044(ra) # 8000207c <exit>
  if(which_dev == 2)
    80002888:	4789                	li	a5,2
    8000288a:	f8f910e3          	bne	s2,a5,8000280a <usertrap+0x62>
    yield();
    8000288e:	00000097          	auipc	ra,0x0
    80002892:	8f8080e7          	jalr	-1800(ra) # 80002186 <yield>
    80002896:	bf95                	j	8000280a <usertrap+0x62>
  int which_dev = 0;
    80002898:	4901                	li	s2,0
    8000289a:	b7d5                	j	8000287e <usertrap+0xd6>

000000008000289c <kerneltrap>:
{
    8000289c:	7179                	addi	sp,sp,-48
    8000289e:	f406                	sd	ra,40(sp)
    800028a0:	f022                	sd	s0,32(sp)
    800028a2:	ec26                	sd	s1,24(sp)
    800028a4:	e84a                	sd	s2,16(sp)
    800028a6:	e44e                	sd	s3,8(sp)
    800028a8:	1800                	addi	s0,sp,48
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800028aa:	14102973          	csrr	s2,sepc
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800028ae:	100024f3          	csrr	s1,sstatus
  asm volatile("csrr %0, scause" : "=r" (x) );
    800028b2:	142029f3          	csrr	s3,scause
  if((sstatus & SSTATUS_SPP) == 0)
    800028b6:	1004f793          	andi	a5,s1,256
    800028ba:	cb85                	beqz	a5,800028ea <kerneltrap+0x4e>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800028bc:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    800028c0:	8b89                	andi	a5,a5,2
  if(intr_get() != 0)
    800028c2:	ef85                	bnez	a5,800028fa <kerneltrap+0x5e>
  if((which_dev = devintr()) == 0){
    800028c4:	00000097          	auipc	ra,0x0
    800028c8:	e42080e7          	jalr	-446(ra) # 80002706 <devintr>
    800028cc:	cd1d                	beqz	a0,8000290a <kerneltrap+0x6e>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    800028ce:	4789                	li	a5,2
    800028d0:	06f50a63          	beq	a0,a5,80002944 <kerneltrap+0xa8>
  asm volatile("csrw sepc, %0" : : "r" (x));
    800028d4:	14191073          	csrw	sepc,s2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800028d8:	10049073          	csrw	sstatus,s1
}
    800028dc:	70a2                	ld	ra,40(sp)
    800028de:	7402                	ld	s0,32(sp)
    800028e0:	64e2                	ld	s1,24(sp)
    800028e2:	6942                	ld	s2,16(sp)
    800028e4:	69a2                	ld	s3,8(sp)
    800028e6:	6145                	addi	sp,sp,48
    800028e8:	8082                	ret
    panic("kerneltrap: not from supervisor mode");
    800028ea:	00006517          	auipc	a0,0x6
    800028ee:	a7650513          	addi	a0,a0,-1418 # 80008360 <states.0+0xc0>
    800028f2:	ffffe097          	auipc	ra,0xffffe
    800028f6:	c3a080e7          	jalr	-966(ra) # 8000052c <panic>
    panic("kerneltrap: interrupts enabled");
    800028fa:	00006517          	auipc	a0,0x6
    800028fe:	a8e50513          	addi	a0,a0,-1394 # 80008388 <states.0+0xe8>
    80002902:	ffffe097          	auipc	ra,0xffffe
    80002906:	c2a080e7          	jalr	-982(ra) # 8000052c <panic>
    printf("scause %p\n", scause);
    8000290a:	85ce                	mv	a1,s3
    8000290c:	00006517          	auipc	a0,0x6
    80002910:	a9c50513          	addi	a0,a0,-1380 # 800083a8 <states.0+0x108>
    80002914:	ffffe097          	auipc	ra,0xffffe
    80002918:	c62080e7          	jalr	-926(ra) # 80000576 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    8000291c:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002920:	14302673          	csrr	a2,stval
    printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
    80002924:	00006517          	auipc	a0,0x6
    80002928:	a9450513          	addi	a0,a0,-1388 # 800083b8 <states.0+0x118>
    8000292c:	ffffe097          	auipc	ra,0xffffe
    80002930:	c4a080e7          	jalr	-950(ra) # 80000576 <printf>
    panic("kerneltrap");
    80002934:	00006517          	auipc	a0,0x6
    80002938:	a9c50513          	addi	a0,a0,-1380 # 800083d0 <states.0+0x130>
    8000293c:	ffffe097          	auipc	ra,0xffffe
    80002940:	bf0080e7          	jalr	-1040(ra) # 8000052c <panic>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    80002944:	fffff097          	auipc	ra,0xfffff
    80002948:	066080e7          	jalr	102(ra) # 800019aa <myproc>
    8000294c:	d541                	beqz	a0,800028d4 <kerneltrap+0x38>
    8000294e:	fffff097          	auipc	ra,0xfffff
    80002952:	05c080e7          	jalr	92(ra) # 800019aa <myproc>
    80002956:	4d18                	lw	a4,24(a0)
    80002958:	478d                	li	a5,3
    8000295a:	f6f71de3          	bne	a4,a5,800028d4 <kerneltrap+0x38>
    yield();
    8000295e:	00000097          	auipc	ra,0x0
    80002962:	828080e7          	jalr	-2008(ra) # 80002186 <yield>
    80002966:	b7bd                	j	800028d4 <kerneltrap+0x38>

0000000080002968 <argraw>:
  return strlen(buf);
}

static uint64
argraw(int n)
{
    80002968:	1101                	addi	sp,sp,-32
    8000296a:	ec06                	sd	ra,24(sp)
    8000296c:	e822                	sd	s0,16(sp)
    8000296e:	e426                	sd	s1,8(sp)
    80002970:	1000                	addi	s0,sp,32
    80002972:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80002974:	fffff097          	auipc	ra,0xfffff
    80002978:	036080e7          	jalr	54(ra) # 800019aa <myproc>
  switch (n) {
    8000297c:	4795                	li	a5,5
    8000297e:	0497e163          	bltu	a5,s1,800029c0 <argraw+0x58>
    80002982:	048a                	slli	s1,s1,0x2
    80002984:	00006717          	auipc	a4,0x6
    80002988:	a8470713          	addi	a4,a4,-1404 # 80008408 <states.0+0x168>
    8000298c:	94ba                	add	s1,s1,a4
    8000298e:	409c                	lw	a5,0(s1)
    80002990:	97ba                	add	a5,a5,a4
    80002992:	8782                	jr	a5
  case 0:
    return p->trapframe->a0;
    80002994:	6d3c                	ld	a5,88(a0)
    80002996:	7ba8                	ld	a0,112(a5)
  case 5:
    return p->trapframe->a5;
  }
  panic("argraw");
  return -1;
}
    80002998:	60e2                	ld	ra,24(sp)
    8000299a:	6442                	ld	s0,16(sp)
    8000299c:	64a2                	ld	s1,8(sp)
    8000299e:	6105                	addi	sp,sp,32
    800029a0:	8082                	ret
    return p->trapframe->a1;
    800029a2:	6d3c                	ld	a5,88(a0)
    800029a4:	7fa8                	ld	a0,120(a5)
    800029a6:	bfcd                	j	80002998 <argraw+0x30>
    return p->trapframe->a2;
    800029a8:	6d3c                	ld	a5,88(a0)
    800029aa:	63c8                	ld	a0,128(a5)
    800029ac:	b7f5                	j	80002998 <argraw+0x30>
    return p->trapframe->a3;
    800029ae:	6d3c                	ld	a5,88(a0)
    800029b0:	67c8                	ld	a0,136(a5)
    800029b2:	b7dd                	j	80002998 <argraw+0x30>
    return p->trapframe->a4;
    800029b4:	6d3c                	ld	a5,88(a0)
    800029b6:	6bc8                	ld	a0,144(a5)
    800029b8:	b7c5                	j	80002998 <argraw+0x30>
    return p->trapframe->a5;
    800029ba:	6d3c                	ld	a5,88(a0)
    800029bc:	6fc8                	ld	a0,152(a5)
    800029be:	bfe9                	j	80002998 <argraw+0x30>
  panic("argraw");
    800029c0:	00006517          	auipc	a0,0x6
    800029c4:	a2050513          	addi	a0,a0,-1504 # 800083e0 <states.0+0x140>
    800029c8:	ffffe097          	auipc	ra,0xffffe
    800029cc:	b64080e7          	jalr	-1180(ra) # 8000052c <panic>

00000000800029d0 <fetchaddr>:
{
    800029d0:	1101                	addi	sp,sp,-32
    800029d2:	ec06                	sd	ra,24(sp)
    800029d4:	e822                	sd	s0,16(sp)
    800029d6:	e426                	sd	s1,8(sp)
    800029d8:	e04a                	sd	s2,0(sp)
    800029da:	1000                	addi	s0,sp,32
    800029dc:	84aa                	mv	s1,a0
    800029de:	892e                	mv	s2,a1
  struct proc *p = myproc();
    800029e0:	fffff097          	auipc	ra,0xfffff
    800029e4:	fca080e7          	jalr	-54(ra) # 800019aa <myproc>
  if(addr >= p->sz || addr+sizeof(uint64) > p->sz)
    800029e8:	653c                	ld	a5,72(a0)
    800029ea:	02f4f863          	bgeu	s1,a5,80002a1a <fetchaddr+0x4a>
    800029ee:	00848713          	addi	a4,s1,8
    800029f2:	02e7e663          	bltu	a5,a4,80002a1e <fetchaddr+0x4e>
  if(copyin(p->pagetable, (char *)ip, addr, sizeof(*ip)) != 0)
    800029f6:	46a1                	li	a3,8
    800029f8:	8626                	mv	a2,s1
    800029fa:	85ca                	mv	a1,s2
    800029fc:	6928                	ld	a0,80(a0)
    800029fe:	fffff097          	auipc	ra,0xfffff
    80002a02:	cd0080e7          	jalr	-816(ra) # 800016ce <copyin>
    80002a06:	00a03533          	snez	a0,a0
    80002a0a:	40a00533          	neg	a0,a0
}
    80002a0e:	60e2                	ld	ra,24(sp)
    80002a10:	6442                	ld	s0,16(sp)
    80002a12:	64a2                	ld	s1,8(sp)
    80002a14:	6902                	ld	s2,0(sp)
    80002a16:	6105                	addi	sp,sp,32
    80002a18:	8082                	ret
    return -1;
    80002a1a:	557d                	li	a0,-1
    80002a1c:	bfcd                	j	80002a0e <fetchaddr+0x3e>
    80002a1e:	557d                	li	a0,-1
    80002a20:	b7fd                	j	80002a0e <fetchaddr+0x3e>

0000000080002a22 <fetchstr>:
{
    80002a22:	7179                	addi	sp,sp,-48
    80002a24:	f406                	sd	ra,40(sp)
    80002a26:	f022                	sd	s0,32(sp)
    80002a28:	ec26                	sd	s1,24(sp)
    80002a2a:	e84a                	sd	s2,16(sp)
    80002a2c:	e44e                	sd	s3,8(sp)
    80002a2e:	1800                	addi	s0,sp,48
    80002a30:	892a                	mv	s2,a0
    80002a32:	84ae                	mv	s1,a1
    80002a34:	89b2                	mv	s3,a2
  struct proc *p = myproc();
    80002a36:	fffff097          	auipc	ra,0xfffff
    80002a3a:	f74080e7          	jalr	-140(ra) # 800019aa <myproc>
  int err = copyinstr(p->pagetable, buf, addr, max);
    80002a3e:	86ce                	mv	a3,s3
    80002a40:	864a                	mv	a2,s2
    80002a42:	85a6                	mv	a1,s1
    80002a44:	6928                	ld	a0,80(a0)
    80002a46:	fffff097          	auipc	ra,0xfffff
    80002a4a:	d16080e7          	jalr	-746(ra) # 8000175c <copyinstr>
  if(err < 0)
    80002a4e:	00054763          	bltz	a0,80002a5c <fetchstr+0x3a>
  return strlen(buf);
    80002a52:	8526                	mv	a0,s1
    80002a54:	ffffe097          	auipc	ra,0xffffe
    80002a58:	3ee080e7          	jalr	1006(ra) # 80000e42 <strlen>
}
    80002a5c:	70a2                	ld	ra,40(sp)
    80002a5e:	7402                	ld	s0,32(sp)
    80002a60:	64e2                	ld	s1,24(sp)
    80002a62:	6942                	ld	s2,16(sp)
    80002a64:	69a2                	ld	s3,8(sp)
    80002a66:	6145                	addi	sp,sp,48
    80002a68:	8082                	ret

0000000080002a6a <argint>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
    80002a6a:	1101                	addi	sp,sp,-32
    80002a6c:	ec06                	sd	ra,24(sp)
    80002a6e:	e822                	sd	s0,16(sp)
    80002a70:	e426                	sd	s1,8(sp)
    80002a72:	1000                	addi	s0,sp,32
    80002a74:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002a76:	00000097          	auipc	ra,0x0
    80002a7a:	ef2080e7          	jalr	-270(ra) # 80002968 <argraw>
    80002a7e:	c088                	sw	a0,0(s1)
  return 0;
}
    80002a80:	4501                	li	a0,0
    80002a82:	60e2                	ld	ra,24(sp)
    80002a84:	6442                	ld	s0,16(sp)
    80002a86:	64a2                	ld	s1,8(sp)
    80002a88:	6105                	addi	sp,sp,32
    80002a8a:	8082                	ret

0000000080002a8c <argaddr>:
// Retrieve an argument as a pointer.
// Doesn't check for legality, since
// copyin/copyout will do that.
int
argaddr(int n, uint64 *ip)
{
    80002a8c:	1101                	addi	sp,sp,-32
    80002a8e:	ec06                	sd	ra,24(sp)
    80002a90:	e822                	sd	s0,16(sp)
    80002a92:	e426                	sd	s1,8(sp)
    80002a94:	1000                	addi	s0,sp,32
    80002a96:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002a98:	00000097          	auipc	ra,0x0
    80002a9c:	ed0080e7          	jalr	-304(ra) # 80002968 <argraw>
    80002aa0:	e088                	sd	a0,0(s1)
  return 0;
}
    80002aa2:	4501                	li	a0,0
    80002aa4:	60e2                	ld	ra,24(sp)
    80002aa6:	6442                	ld	s0,16(sp)
    80002aa8:	64a2                	ld	s1,8(sp)
    80002aaa:	6105                	addi	sp,sp,32
    80002aac:	8082                	ret

0000000080002aae <argstr>:
// Fetch the nth word-sized system call argument as a null-terminated string.
// Copies into buf, at most max.
// Returns string length if OK (including nul), -1 if error.
int
argstr(int n, char *buf, int max)
{
    80002aae:	1101                	addi	sp,sp,-32
    80002ab0:	ec06                	sd	ra,24(sp)
    80002ab2:	e822                	sd	s0,16(sp)
    80002ab4:	e426                	sd	s1,8(sp)
    80002ab6:	e04a                	sd	s2,0(sp)
    80002ab8:	1000                	addi	s0,sp,32
    80002aba:	84ae                	mv	s1,a1
    80002abc:	8932                	mv	s2,a2
  *ip = argraw(n);
    80002abe:	00000097          	auipc	ra,0x0
    80002ac2:	eaa080e7          	jalr	-342(ra) # 80002968 <argraw>
  uint64 addr;
  if(argaddr(n, &addr) < 0)
    return -1;
  return fetchstr(addr, buf, max);
    80002ac6:	864a                	mv	a2,s2
    80002ac8:	85a6                	mv	a1,s1
    80002aca:	00000097          	auipc	ra,0x0
    80002ace:	f58080e7          	jalr	-168(ra) # 80002a22 <fetchstr>
}
    80002ad2:	60e2                	ld	ra,24(sp)
    80002ad4:	6442                	ld	s0,16(sp)
    80002ad6:	64a2                	ld	s1,8(sp)
    80002ad8:	6902                	ld	s2,0(sp)
    80002ada:	6105                	addi	sp,sp,32
    80002adc:	8082                	ret

0000000080002ade <syscall>:
[SYS_symlink] sys_symlink,
};

void
syscall(void)
{
    80002ade:	1101                	addi	sp,sp,-32
    80002ae0:	ec06                	sd	ra,24(sp)
    80002ae2:	e822                	sd	s0,16(sp)
    80002ae4:	e426                	sd	s1,8(sp)
    80002ae6:	e04a                	sd	s2,0(sp)
    80002ae8:	1000                	addi	s0,sp,32
  int num;
  struct proc *p = myproc();
    80002aea:	fffff097          	auipc	ra,0xfffff
    80002aee:	ec0080e7          	jalr	-320(ra) # 800019aa <myproc>
    80002af2:	84aa                	mv	s1,a0

  num = p->trapframe->a7;
    80002af4:	05853903          	ld	s2,88(a0)
    80002af8:	0a893783          	ld	a5,168(s2)
    80002afc:	0007869b          	sext.w	a3,a5
  if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
    80002b00:	37fd                	addiw	a5,a5,-1
    80002b02:	4759                	li	a4,22
    80002b04:	00f76f63          	bltu	a4,a5,80002b22 <syscall+0x44>
    80002b08:	00369713          	slli	a4,a3,0x3
    80002b0c:	00006797          	auipc	a5,0x6
    80002b10:	91478793          	addi	a5,a5,-1772 # 80008420 <syscalls>
    80002b14:	97ba                	add	a5,a5,a4
    80002b16:	639c                	ld	a5,0(a5)
    80002b18:	c789                	beqz	a5,80002b22 <syscall+0x44>
    p->trapframe->a0 = syscalls[num]();
    80002b1a:	9782                	jalr	a5
    80002b1c:	06a93823          	sd	a0,112(s2)
    80002b20:	a839                	j	80002b3e <syscall+0x60>
  } else {
    printf("%d %s: unknown sys call %d\n",
    80002b22:	15848613          	addi	a2,s1,344
    80002b26:	5c8c                	lw	a1,56(s1)
    80002b28:	00006517          	auipc	a0,0x6
    80002b2c:	8c050513          	addi	a0,a0,-1856 # 800083e8 <states.0+0x148>
    80002b30:	ffffe097          	auipc	ra,0xffffe
    80002b34:	a46080e7          	jalr	-1466(ra) # 80000576 <printf>
            p->pid, p->name, num);
    p->trapframe->a0 = -1;
    80002b38:	6cbc                	ld	a5,88(s1)
    80002b3a:	577d                	li	a4,-1
    80002b3c:	fbb8                	sd	a4,112(a5)
  }
}
    80002b3e:	60e2                	ld	ra,24(sp)
    80002b40:	6442                	ld	s0,16(sp)
    80002b42:	64a2                	ld	s1,8(sp)
    80002b44:	6902                	ld	s2,0(sp)
    80002b46:	6105                	addi	sp,sp,32
    80002b48:	8082                	ret

0000000080002b4a <sys_exit>:
#include "spinlock.h"
#include "proc.h"

uint64
sys_exit(void)
{
    80002b4a:	1101                	addi	sp,sp,-32
    80002b4c:	ec06                	sd	ra,24(sp)
    80002b4e:	e822                	sd	s0,16(sp)
    80002b50:	1000                	addi	s0,sp,32
  int n;
  if(argint(0, &n) < 0)
    80002b52:	fec40593          	addi	a1,s0,-20
    80002b56:	4501                	li	a0,0
    80002b58:	00000097          	auipc	ra,0x0
    80002b5c:	f12080e7          	jalr	-238(ra) # 80002a6a <argint>
    return -1;
    80002b60:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002b62:	00054963          	bltz	a0,80002b74 <sys_exit+0x2a>
  exit(n);
    80002b66:	fec42503          	lw	a0,-20(s0)
    80002b6a:	fffff097          	auipc	ra,0xfffff
    80002b6e:	512080e7          	jalr	1298(ra) # 8000207c <exit>
  return 0;  // not reached
    80002b72:	4781                	li	a5,0
}
    80002b74:	853e                	mv	a0,a5
    80002b76:	60e2                	ld	ra,24(sp)
    80002b78:	6442                	ld	s0,16(sp)
    80002b7a:	6105                	addi	sp,sp,32
    80002b7c:	8082                	ret

0000000080002b7e <sys_getpid>:

uint64
sys_getpid(void)
{
    80002b7e:	1141                	addi	sp,sp,-16
    80002b80:	e406                	sd	ra,8(sp)
    80002b82:	e022                	sd	s0,0(sp)
    80002b84:	0800                	addi	s0,sp,16
  return myproc()->pid;
    80002b86:	fffff097          	auipc	ra,0xfffff
    80002b8a:	e24080e7          	jalr	-476(ra) # 800019aa <myproc>
}
    80002b8e:	5d08                	lw	a0,56(a0)
    80002b90:	60a2                	ld	ra,8(sp)
    80002b92:	6402                	ld	s0,0(sp)
    80002b94:	0141                	addi	sp,sp,16
    80002b96:	8082                	ret

0000000080002b98 <sys_fork>:

uint64
sys_fork(void)
{
    80002b98:	1141                	addi	sp,sp,-16
    80002b9a:	e406                	sd	ra,8(sp)
    80002b9c:	e022                	sd	s0,0(sp)
    80002b9e:	0800                	addi	s0,sp,16
  return fork();
    80002ba0:	fffff097          	auipc	ra,0xfffff
    80002ba4:	1ce080e7          	jalr	462(ra) # 80001d6e <fork>
}
    80002ba8:	60a2                	ld	ra,8(sp)
    80002baa:	6402                	ld	s0,0(sp)
    80002bac:	0141                	addi	sp,sp,16
    80002bae:	8082                	ret

0000000080002bb0 <sys_wait>:

uint64
sys_wait(void)
{
    80002bb0:	1101                	addi	sp,sp,-32
    80002bb2:	ec06                	sd	ra,24(sp)
    80002bb4:	e822                	sd	s0,16(sp)
    80002bb6:	1000                	addi	s0,sp,32
  uint64 p;
  if(argaddr(0, &p) < 0)
    80002bb8:	fe840593          	addi	a1,s0,-24
    80002bbc:	4501                	li	a0,0
    80002bbe:	00000097          	auipc	ra,0x0
    80002bc2:	ece080e7          	jalr	-306(ra) # 80002a8c <argaddr>
    80002bc6:	87aa                	mv	a5,a0
    return -1;
    80002bc8:	557d                	li	a0,-1
  if(argaddr(0, &p) < 0)
    80002bca:	0007c863          	bltz	a5,80002bda <sys_wait+0x2a>
  return wait(p);
    80002bce:	fe843503          	ld	a0,-24(s0)
    80002bd2:	fffff097          	auipc	ra,0xfffff
    80002bd6:	66e080e7          	jalr	1646(ra) # 80002240 <wait>
}
    80002bda:	60e2                	ld	ra,24(sp)
    80002bdc:	6442                	ld	s0,16(sp)
    80002bde:	6105                	addi	sp,sp,32
    80002be0:	8082                	ret

0000000080002be2 <sys_sbrk>:

uint64
sys_sbrk(void)
{
    80002be2:	7179                	addi	sp,sp,-48
    80002be4:	f406                	sd	ra,40(sp)
    80002be6:	f022                	sd	s0,32(sp)
    80002be8:	ec26                	sd	s1,24(sp)
    80002bea:	1800                	addi	s0,sp,48
  int addr;
  int n;

  if(argint(0, &n) < 0)
    80002bec:	fdc40593          	addi	a1,s0,-36
    80002bf0:	4501                	li	a0,0
    80002bf2:	00000097          	auipc	ra,0x0
    80002bf6:	e78080e7          	jalr	-392(ra) # 80002a6a <argint>
    80002bfa:	87aa                	mv	a5,a0
    return -1;
    80002bfc:	557d                	li	a0,-1
  if(argint(0, &n) < 0)
    80002bfe:	0207c063          	bltz	a5,80002c1e <sys_sbrk+0x3c>
  addr = myproc()->sz;
    80002c02:	fffff097          	auipc	ra,0xfffff
    80002c06:	da8080e7          	jalr	-600(ra) # 800019aa <myproc>
    80002c0a:	4524                	lw	s1,72(a0)
  if(growproc(n) < 0)
    80002c0c:	fdc42503          	lw	a0,-36(s0)
    80002c10:	fffff097          	auipc	ra,0xfffff
    80002c14:	0e6080e7          	jalr	230(ra) # 80001cf6 <growproc>
    80002c18:	00054863          	bltz	a0,80002c28 <sys_sbrk+0x46>
    return -1;
  return addr;
    80002c1c:	8526                	mv	a0,s1
}
    80002c1e:	70a2                	ld	ra,40(sp)
    80002c20:	7402                	ld	s0,32(sp)
    80002c22:	64e2                	ld	s1,24(sp)
    80002c24:	6145                	addi	sp,sp,48
    80002c26:	8082                	ret
    return -1;
    80002c28:	557d                	li	a0,-1
    80002c2a:	bfd5                	j	80002c1e <sys_sbrk+0x3c>

0000000080002c2c <sys_sleep>:

uint64
sys_sleep(void)
{
    80002c2c:	7139                	addi	sp,sp,-64
    80002c2e:	fc06                	sd	ra,56(sp)
    80002c30:	f822                	sd	s0,48(sp)
    80002c32:	f426                	sd	s1,40(sp)
    80002c34:	f04a                	sd	s2,32(sp)
    80002c36:	ec4e                	sd	s3,24(sp)
    80002c38:	0080                	addi	s0,sp,64
  int n;
  uint ticks0;

  if(argint(0, &n) < 0)
    80002c3a:	fcc40593          	addi	a1,s0,-52
    80002c3e:	4501                	li	a0,0
    80002c40:	00000097          	auipc	ra,0x0
    80002c44:	e2a080e7          	jalr	-470(ra) # 80002a6a <argint>
    return -1;
    80002c48:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002c4a:	06054563          	bltz	a0,80002cb4 <sys_sleep+0x88>
  acquire(&tickslock);
    80002c4e:	00010517          	auipc	a0,0x10
    80002c52:	87a50513          	addi	a0,a0,-1926 # 800124c8 <tickslock>
    80002c56:	ffffe097          	auipc	ra,0xffffe
    80002c5a:	f6c080e7          	jalr	-148(ra) # 80000bc2 <acquire>
  ticks0 = ticks;
    80002c5e:	00006917          	auipc	s2,0x6
    80002c62:	3d292903          	lw	s2,978(s2) # 80009030 <ticks>
  while(ticks - ticks0 < n){
    80002c66:	fcc42783          	lw	a5,-52(s0)
    80002c6a:	cf85                	beqz	a5,80002ca2 <sys_sleep+0x76>
    if(myproc()->killed){
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
    80002c6c:	00010997          	auipc	s3,0x10
    80002c70:	85c98993          	addi	s3,s3,-1956 # 800124c8 <tickslock>
    80002c74:	00006497          	auipc	s1,0x6
    80002c78:	3bc48493          	addi	s1,s1,956 # 80009030 <ticks>
    if(myproc()->killed){
    80002c7c:	fffff097          	auipc	ra,0xfffff
    80002c80:	d2e080e7          	jalr	-722(ra) # 800019aa <myproc>
    80002c84:	591c                	lw	a5,48(a0)
    80002c86:	ef9d                	bnez	a5,80002cc4 <sys_sleep+0x98>
    sleep(&ticks, &tickslock);
    80002c88:	85ce                	mv	a1,s3
    80002c8a:	8526                	mv	a0,s1
    80002c8c:	fffff097          	auipc	ra,0xfffff
    80002c90:	536080e7          	jalr	1334(ra) # 800021c2 <sleep>
  while(ticks - ticks0 < n){
    80002c94:	409c                	lw	a5,0(s1)
    80002c96:	412787bb          	subw	a5,a5,s2
    80002c9a:	fcc42703          	lw	a4,-52(s0)
    80002c9e:	fce7efe3          	bltu	a5,a4,80002c7c <sys_sleep+0x50>
  }
  release(&tickslock);
    80002ca2:	00010517          	auipc	a0,0x10
    80002ca6:	82650513          	addi	a0,a0,-2010 # 800124c8 <tickslock>
    80002caa:	ffffe097          	auipc	ra,0xffffe
    80002cae:	fcc080e7          	jalr	-52(ra) # 80000c76 <release>
  return 0;
    80002cb2:	4781                	li	a5,0
}
    80002cb4:	853e                	mv	a0,a5
    80002cb6:	70e2                	ld	ra,56(sp)
    80002cb8:	7442                	ld	s0,48(sp)
    80002cba:	74a2                	ld	s1,40(sp)
    80002cbc:	7902                	ld	s2,32(sp)
    80002cbe:	69e2                	ld	s3,24(sp)
    80002cc0:	6121                	addi	sp,sp,64
    80002cc2:	8082                	ret
      release(&tickslock);
    80002cc4:	00010517          	auipc	a0,0x10
    80002cc8:	80450513          	addi	a0,a0,-2044 # 800124c8 <tickslock>
    80002ccc:	ffffe097          	auipc	ra,0xffffe
    80002cd0:	faa080e7          	jalr	-86(ra) # 80000c76 <release>
      return -1;
    80002cd4:	57fd                	li	a5,-1
    80002cd6:	bff9                	j	80002cb4 <sys_sleep+0x88>

0000000080002cd8 <sys_kill>:

uint64
sys_kill(void)
{
    80002cd8:	1101                	addi	sp,sp,-32
    80002cda:	ec06                	sd	ra,24(sp)
    80002cdc:	e822                	sd	s0,16(sp)
    80002cde:	1000                	addi	s0,sp,32
  int pid;

  if(argint(0, &pid) < 0)
    80002ce0:	fec40593          	addi	a1,s0,-20
    80002ce4:	4501                	li	a0,0
    80002ce6:	00000097          	auipc	ra,0x0
    80002cea:	d84080e7          	jalr	-636(ra) # 80002a6a <argint>
    80002cee:	87aa                	mv	a5,a0
    return -1;
    80002cf0:	557d                	li	a0,-1
  if(argint(0, &pid) < 0)
    80002cf2:	0007c863          	bltz	a5,80002d02 <sys_kill+0x2a>
  return kill(pid);
    80002cf6:	fec42503          	lw	a0,-20(s0)
    80002cfa:	fffff097          	auipc	ra,0xfffff
    80002cfe:	6b2080e7          	jalr	1714(ra) # 800023ac <kill>
}
    80002d02:	60e2                	ld	ra,24(sp)
    80002d04:	6442                	ld	s0,16(sp)
    80002d06:	6105                	addi	sp,sp,32
    80002d08:	8082                	ret

0000000080002d0a <sys_uptime>:

// return how many clock tick interrupts have occurred
// since start.
uint64
sys_uptime(void)
{
    80002d0a:	1101                	addi	sp,sp,-32
    80002d0c:	ec06                	sd	ra,24(sp)
    80002d0e:	e822                	sd	s0,16(sp)
    80002d10:	e426                	sd	s1,8(sp)
    80002d12:	1000                	addi	s0,sp,32
  uint xticks;

  acquire(&tickslock);
    80002d14:	0000f517          	auipc	a0,0xf
    80002d18:	7b450513          	addi	a0,a0,1972 # 800124c8 <tickslock>
    80002d1c:	ffffe097          	auipc	ra,0xffffe
    80002d20:	ea6080e7          	jalr	-346(ra) # 80000bc2 <acquire>
  xticks = ticks;
    80002d24:	00006497          	auipc	s1,0x6
    80002d28:	30c4a483          	lw	s1,780(s1) # 80009030 <ticks>
  release(&tickslock);
    80002d2c:	0000f517          	auipc	a0,0xf
    80002d30:	79c50513          	addi	a0,a0,1948 # 800124c8 <tickslock>
    80002d34:	ffffe097          	auipc	ra,0xffffe
    80002d38:	f42080e7          	jalr	-190(ra) # 80000c76 <release>
  return xticks;
}
    80002d3c:	02049513          	slli	a0,s1,0x20
    80002d40:	9101                	srli	a0,a0,0x20
    80002d42:	60e2                	ld	ra,24(sp)
    80002d44:	6442                	ld	s0,16(sp)
    80002d46:	64a2                	ld	s1,8(sp)
    80002d48:	6105                	addi	sp,sp,32
    80002d4a:	8082                	ret

0000000080002d4c <binit>:
  struct buf head;
} bcache;

void
binit(void)
{
    80002d4c:	7179                	addi	sp,sp,-48
    80002d4e:	f406                	sd	ra,40(sp)
    80002d50:	f022                	sd	s0,32(sp)
    80002d52:	ec26                	sd	s1,24(sp)
    80002d54:	e84a                	sd	s2,16(sp)
    80002d56:	e44e                	sd	s3,8(sp)
    80002d58:	e052                	sd	s4,0(sp)
    80002d5a:	1800                	addi	s0,sp,48
  struct buf *b;

  initlock(&bcache.lock, "bcache");
    80002d5c:	00005597          	auipc	a1,0x5
    80002d60:	78458593          	addi	a1,a1,1924 # 800084e0 <syscalls+0xc0>
    80002d64:	0000f517          	auipc	a0,0xf
    80002d68:	77c50513          	addi	a0,a0,1916 # 800124e0 <bcache>
    80002d6c:	ffffe097          	auipc	ra,0xffffe
    80002d70:	dc6080e7          	jalr	-570(ra) # 80000b32 <initlock>

  // Create linked list of buffers
  bcache.head.prev = &bcache.head;
    80002d74:	00017797          	auipc	a5,0x17
    80002d78:	76c78793          	addi	a5,a5,1900 # 8001a4e0 <bcache+0x8000>
    80002d7c:	00018717          	auipc	a4,0x18
    80002d80:	9cc70713          	addi	a4,a4,-1588 # 8001a748 <bcache+0x8268>
    80002d84:	2ae7b823          	sd	a4,688(a5)
  bcache.head.next = &bcache.head;
    80002d88:	2ae7bc23          	sd	a4,696(a5)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002d8c:	0000f497          	auipc	s1,0xf
    80002d90:	76c48493          	addi	s1,s1,1900 # 800124f8 <bcache+0x18>
    b->next = bcache.head.next;
    80002d94:	893e                	mv	s2,a5
    b->prev = &bcache.head;
    80002d96:	89ba                	mv	s3,a4
    initsleeplock(&b->lock, "buffer");
    80002d98:	00005a17          	auipc	s4,0x5
    80002d9c:	750a0a13          	addi	s4,s4,1872 # 800084e8 <syscalls+0xc8>
    b->next = bcache.head.next;
    80002da0:	2b893783          	ld	a5,696(s2)
    80002da4:	e8bc                	sd	a5,80(s1)
    b->prev = &bcache.head;
    80002da6:	0534b423          	sd	s3,72(s1)
    initsleeplock(&b->lock, "buffer");
    80002daa:	85d2                	mv	a1,s4
    80002dac:	01048513          	addi	a0,s1,16
    80002db0:	00002097          	auipc	ra,0x2
    80002db4:	daa080e7          	jalr	-598(ra) # 80004b5a <initsleeplock>
    bcache.head.next->prev = b;
    80002db8:	2b893783          	ld	a5,696(s2)
    80002dbc:	e7a4                	sd	s1,72(a5)
    bcache.head.next = b;
    80002dbe:	2a993c23          	sd	s1,696(s2)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    80002dc2:	45848493          	addi	s1,s1,1112
    80002dc6:	fd349de3          	bne	s1,s3,80002da0 <binit+0x54>
  }
}
    80002dca:	70a2                	ld	ra,40(sp)
    80002dcc:	7402                	ld	s0,32(sp)
    80002dce:	64e2                	ld	s1,24(sp)
    80002dd0:	6942                	ld	s2,16(sp)
    80002dd2:	69a2                	ld	s3,8(sp)
    80002dd4:	6a02                	ld	s4,0(sp)
    80002dd6:	6145                	addi	sp,sp,48
    80002dd8:	8082                	ret

0000000080002dda <bread>:
}

// Return a locked buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
    80002dda:	7179                	addi	sp,sp,-48
    80002ddc:	f406                	sd	ra,40(sp)
    80002dde:	f022                	sd	s0,32(sp)
    80002de0:	ec26                	sd	s1,24(sp)
    80002de2:	e84a                	sd	s2,16(sp)
    80002de4:	e44e                	sd	s3,8(sp)
    80002de6:	1800                	addi	s0,sp,48
    80002de8:	892a                	mv	s2,a0
    80002dea:	89ae                	mv	s3,a1
  acquire(&bcache.lock);
    80002dec:	0000f517          	auipc	a0,0xf
    80002df0:	6f450513          	addi	a0,a0,1780 # 800124e0 <bcache>
    80002df4:	ffffe097          	auipc	ra,0xffffe
    80002df8:	dce080e7          	jalr	-562(ra) # 80000bc2 <acquire>
  for(b = bcache.head.next; b != &bcache.head; b = b->next){
    80002dfc:	00018497          	auipc	s1,0x18
    80002e00:	99c4b483          	ld	s1,-1636(s1) # 8001a798 <bcache+0x82b8>
    80002e04:	00018797          	auipc	a5,0x18
    80002e08:	94478793          	addi	a5,a5,-1724 # 8001a748 <bcache+0x8268>
    80002e0c:	02f48f63          	beq	s1,a5,80002e4a <bread+0x70>
    80002e10:	873e                	mv	a4,a5
    80002e12:	a021                	j	80002e1a <bread+0x40>
    80002e14:	68a4                	ld	s1,80(s1)
    80002e16:	02e48a63          	beq	s1,a4,80002e4a <bread+0x70>
    if(b->dev == dev && b->blockno == blockno){
    80002e1a:	449c                	lw	a5,8(s1)
    80002e1c:	ff279ce3          	bne	a5,s2,80002e14 <bread+0x3a>
    80002e20:	44dc                	lw	a5,12(s1)
    80002e22:	ff3799e3          	bne	a5,s3,80002e14 <bread+0x3a>
      b->refcnt++;
    80002e26:	40bc                	lw	a5,64(s1)
    80002e28:	2785                	addiw	a5,a5,1
    80002e2a:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    80002e2c:	0000f517          	auipc	a0,0xf
    80002e30:	6b450513          	addi	a0,a0,1716 # 800124e0 <bcache>
    80002e34:	ffffe097          	auipc	ra,0xffffe
    80002e38:	e42080e7          	jalr	-446(ra) # 80000c76 <release>
      acquiresleep(&b->lock);
    80002e3c:	01048513          	addi	a0,s1,16
    80002e40:	00002097          	auipc	ra,0x2
    80002e44:	d54080e7          	jalr	-684(ra) # 80004b94 <acquiresleep>
      return b;
    80002e48:	a8b9                	j	80002ea6 <bread+0xcc>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80002e4a:	00018497          	auipc	s1,0x18
    80002e4e:	9464b483          	ld	s1,-1722(s1) # 8001a790 <bcache+0x82b0>
    80002e52:	00018797          	auipc	a5,0x18
    80002e56:	8f678793          	addi	a5,a5,-1802 # 8001a748 <bcache+0x8268>
    80002e5a:	00f48863          	beq	s1,a5,80002e6a <bread+0x90>
    80002e5e:	873e                	mv	a4,a5
    if(b->refcnt == 0) {
    80002e60:	40bc                	lw	a5,64(s1)
    80002e62:	cf81                	beqz	a5,80002e7a <bread+0xa0>
  for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
    80002e64:	64a4                	ld	s1,72(s1)
    80002e66:	fee49de3          	bne	s1,a4,80002e60 <bread+0x86>
  panic("bget: no buffers");
    80002e6a:	00005517          	auipc	a0,0x5
    80002e6e:	68650513          	addi	a0,a0,1670 # 800084f0 <syscalls+0xd0>
    80002e72:	ffffd097          	auipc	ra,0xffffd
    80002e76:	6ba080e7          	jalr	1722(ra) # 8000052c <panic>
      b->dev = dev;
    80002e7a:	0124a423          	sw	s2,8(s1)
      b->blockno = blockno;
    80002e7e:	0134a623          	sw	s3,12(s1)
      b->valid = 0;
    80002e82:	0004a023          	sw	zero,0(s1)
      b->refcnt = 1;
    80002e86:	4785                	li	a5,1
    80002e88:	c0bc                	sw	a5,64(s1)
      release(&bcache.lock);
    80002e8a:	0000f517          	auipc	a0,0xf
    80002e8e:	65650513          	addi	a0,a0,1622 # 800124e0 <bcache>
    80002e92:	ffffe097          	auipc	ra,0xffffe
    80002e96:	de4080e7          	jalr	-540(ra) # 80000c76 <release>
      acquiresleep(&b->lock);
    80002e9a:	01048513          	addi	a0,s1,16
    80002e9e:	00002097          	auipc	ra,0x2
    80002ea2:	cf6080e7          	jalr	-778(ra) # 80004b94 <acquiresleep>
  struct buf *b;

  b = bget(dev, blockno);
  if(!b->valid) {
    80002ea6:	409c                	lw	a5,0(s1)
    80002ea8:	cb89                	beqz	a5,80002eba <bread+0xe0>
    virtio_disk_rw(b, 0);
    b->valid = 1;
  }
  return b;
}
    80002eaa:	8526                	mv	a0,s1
    80002eac:	70a2                	ld	ra,40(sp)
    80002eae:	7402                	ld	s0,32(sp)
    80002eb0:	64e2                	ld	s1,24(sp)
    80002eb2:	6942                	ld	s2,16(sp)
    80002eb4:	69a2                	ld	s3,8(sp)
    80002eb6:	6145                	addi	sp,sp,48
    80002eb8:	8082                	ret
    virtio_disk_rw(b, 0);
    80002eba:	4581                	li	a1,0
    80002ebc:	8526                	mv	a0,s1
    80002ebe:	00004097          	auipc	ra,0x4
    80002ec2:	9c4080e7          	jalr	-1596(ra) # 80006882 <virtio_disk_rw>
    b->valid = 1;
    80002ec6:	4785                	li	a5,1
    80002ec8:	c09c                	sw	a5,0(s1)
  return b;
    80002eca:	b7c5                	j	80002eaa <bread+0xd0>

0000000080002ecc <bwrite>:

// Write b's contents to disk.  Must be locked.
void
bwrite(struct buf *b)
{
    80002ecc:	1101                	addi	sp,sp,-32
    80002ece:	ec06                	sd	ra,24(sp)
    80002ed0:	e822                	sd	s0,16(sp)
    80002ed2:	e426                	sd	s1,8(sp)
    80002ed4:	1000                	addi	s0,sp,32
    80002ed6:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80002ed8:	0541                	addi	a0,a0,16
    80002eda:	00002097          	auipc	ra,0x2
    80002ede:	d54080e7          	jalr	-684(ra) # 80004c2e <holdingsleep>
    80002ee2:	cd01                	beqz	a0,80002efa <bwrite+0x2e>
    panic("bwrite");
  virtio_disk_rw(b, 1);
    80002ee4:	4585                	li	a1,1
    80002ee6:	8526                	mv	a0,s1
    80002ee8:	00004097          	auipc	ra,0x4
    80002eec:	99a080e7          	jalr	-1638(ra) # 80006882 <virtio_disk_rw>
}
    80002ef0:	60e2                	ld	ra,24(sp)
    80002ef2:	6442                	ld	s0,16(sp)
    80002ef4:	64a2                	ld	s1,8(sp)
    80002ef6:	6105                	addi	sp,sp,32
    80002ef8:	8082                	ret
    panic("bwrite");
    80002efa:	00005517          	auipc	a0,0x5
    80002efe:	60e50513          	addi	a0,a0,1550 # 80008508 <syscalls+0xe8>
    80002f02:	ffffd097          	auipc	ra,0xffffd
    80002f06:	62a080e7          	jalr	1578(ra) # 8000052c <panic>

0000000080002f0a <brelse>:

// Release a locked buffer.
// Move to the head of the most-recently-used list.
void
brelse(struct buf *b)
{
    80002f0a:	1101                	addi	sp,sp,-32
    80002f0c:	ec06                	sd	ra,24(sp)
    80002f0e:	e822                	sd	s0,16(sp)
    80002f10:	e426                	sd	s1,8(sp)
    80002f12:	e04a                	sd	s2,0(sp)
    80002f14:	1000                	addi	s0,sp,32
    80002f16:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80002f18:	01050913          	addi	s2,a0,16
    80002f1c:	854a                	mv	a0,s2
    80002f1e:	00002097          	auipc	ra,0x2
    80002f22:	d10080e7          	jalr	-752(ra) # 80004c2e <holdingsleep>
    80002f26:	c92d                	beqz	a0,80002f98 <brelse+0x8e>
    panic("brelse");

  releasesleep(&b->lock);
    80002f28:	854a                	mv	a0,s2
    80002f2a:	00002097          	auipc	ra,0x2
    80002f2e:	cc0080e7          	jalr	-832(ra) # 80004bea <releasesleep>

  acquire(&bcache.lock);
    80002f32:	0000f517          	auipc	a0,0xf
    80002f36:	5ae50513          	addi	a0,a0,1454 # 800124e0 <bcache>
    80002f3a:	ffffe097          	auipc	ra,0xffffe
    80002f3e:	c88080e7          	jalr	-888(ra) # 80000bc2 <acquire>
  b->refcnt--;
    80002f42:	40bc                	lw	a5,64(s1)
    80002f44:	37fd                	addiw	a5,a5,-1
    80002f46:	0007871b          	sext.w	a4,a5
    80002f4a:	c0bc                	sw	a5,64(s1)
  if (b->refcnt == 0) {
    80002f4c:	eb05                	bnez	a4,80002f7c <brelse+0x72>
    // no one is waiting for it.
    b->next->prev = b->prev;
    80002f4e:	68bc                	ld	a5,80(s1)
    80002f50:	64b8                	ld	a4,72(s1)
    80002f52:	e7b8                	sd	a4,72(a5)
    b->prev->next = b->next;
    80002f54:	64bc                	ld	a5,72(s1)
    80002f56:	68b8                	ld	a4,80(s1)
    80002f58:	ebb8                	sd	a4,80(a5)
    b->next = bcache.head.next;
    80002f5a:	00017797          	auipc	a5,0x17
    80002f5e:	58678793          	addi	a5,a5,1414 # 8001a4e0 <bcache+0x8000>
    80002f62:	2b87b703          	ld	a4,696(a5)
    80002f66:	e8b8                	sd	a4,80(s1)
    b->prev = &bcache.head;
    80002f68:	00017717          	auipc	a4,0x17
    80002f6c:	7e070713          	addi	a4,a4,2016 # 8001a748 <bcache+0x8268>
    80002f70:	e4b8                	sd	a4,72(s1)
    bcache.head.next->prev = b;
    80002f72:	2b87b703          	ld	a4,696(a5)
    80002f76:	e724                	sd	s1,72(a4)
    bcache.head.next = b;
    80002f78:	2a97bc23          	sd	s1,696(a5)
  }
  
  release(&bcache.lock);
    80002f7c:	0000f517          	auipc	a0,0xf
    80002f80:	56450513          	addi	a0,a0,1380 # 800124e0 <bcache>
    80002f84:	ffffe097          	auipc	ra,0xffffe
    80002f88:	cf2080e7          	jalr	-782(ra) # 80000c76 <release>
}
    80002f8c:	60e2                	ld	ra,24(sp)
    80002f8e:	6442                	ld	s0,16(sp)
    80002f90:	64a2                	ld	s1,8(sp)
    80002f92:	6902                	ld	s2,0(sp)
    80002f94:	6105                	addi	sp,sp,32
    80002f96:	8082                	ret
    panic("brelse");
    80002f98:	00005517          	auipc	a0,0x5
    80002f9c:	57850513          	addi	a0,a0,1400 # 80008510 <syscalls+0xf0>
    80002fa0:	ffffd097          	auipc	ra,0xffffd
    80002fa4:	58c080e7          	jalr	1420(ra) # 8000052c <panic>

0000000080002fa8 <bpin>:

void
bpin(struct buf *b) {
    80002fa8:	1101                	addi	sp,sp,-32
    80002faa:	ec06                	sd	ra,24(sp)
    80002fac:	e822                	sd	s0,16(sp)
    80002fae:	e426                	sd	s1,8(sp)
    80002fb0:	1000                	addi	s0,sp,32
    80002fb2:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80002fb4:	0000f517          	auipc	a0,0xf
    80002fb8:	52c50513          	addi	a0,a0,1324 # 800124e0 <bcache>
    80002fbc:	ffffe097          	auipc	ra,0xffffe
    80002fc0:	c06080e7          	jalr	-1018(ra) # 80000bc2 <acquire>
  b->refcnt++;
    80002fc4:	40bc                	lw	a5,64(s1)
    80002fc6:	2785                	addiw	a5,a5,1
    80002fc8:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    80002fca:	0000f517          	auipc	a0,0xf
    80002fce:	51650513          	addi	a0,a0,1302 # 800124e0 <bcache>
    80002fd2:	ffffe097          	auipc	ra,0xffffe
    80002fd6:	ca4080e7          	jalr	-860(ra) # 80000c76 <release>
}
    80002fda:	60e2                	ld	ra,24(sp)
    80002fdc:	6442                	ld	s0,16(sp)
    80002fde:	64a2                	ld	s1,8(sp)
    80002fe0:	6105                	addi	sp,sp,32
    80002fe2:	8082                	ret

0000000080002fe4 <bunpin>:

void
bunpin(struct buf *b) {
    80002fe4:	1101                	addi	sp,sp,-32
    80002fe6:	ec06                	sd	ra,24(sp)
    80002fe8:	e822                	sd	s0,16(sp)
    80002fea:	e426                	sd	s1,8(sp)
    80002fec:	1000                	addi	s0,sp,32
    80002fee:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80002ff0:	0000f517          	auipc	a0,0xf
    80002ff4:	4f050513          	addi	a0,a0,1264 # 800124e0 <bcache>
    80002ff8:	ffffe097          	auipc	ra,0xffffe
    80002ffc:	bca080e7          	jalr	-1078(ra) # 80000bc2 <acquire>
  b->refcnt--;
    80003000:	40bc                	lw	a5,64(s1)
    80003002:	37fd                	addiw	a5,a5,-1
    80003004:	c0bc                	sw	a5,64(s1)
  release(&bcache.lock);
    80003006:	0000f517          	auipc	a0,0xf
    8000300a:	4da50513          	addi	a0,a0,1242 # 800124e0 <bcache>
    8000300e:	ffffe097          	auipc	ra,0xffffe
    80003012:	c68080e7          	jalr	-920(ra) # 80000c76 <release>
}
    80003016:	60e2                	ld	ra,24(sp)
    80003018:	6442                	ld	s0,16(sp)
    8000301a:	64a2                	ld	s1,8(sp)
    8000301c:	6105                	addi	sp,sp,32
    8000301e:	8082                	ret

0000000080003020 <bfree>:
}

// Free a disk block.
static void
bfree(int dev, uint b)
{
    80003020:	1101                	addi	sp,sp,-32
    80003022:	ec06                	sd	ra,24(sp)
    80003024:	e822                	sd	s0,16(sp)
    80003026:	e426                	sd	s1,8(sp)
    80003028:	e04a                	sd	s2,0(sp)
    8000302a:	1000                	addi	s0,sp,32
    8000302c:	84ae                	mv	s1,a1
  struct buf *bp;
  int bi, m;

  bp = bread(dev, BBLOCK(b, sb));
    8000302e:	00d5d59b          	srliw	a1,a1,0xd
    80003032:	00018797          	auipc	a5,0x18
    80003036:	b8a7a783          	lw	a5,-1142(a5) # 8001abbc <sb+0x1c>
    8000303a:	9dbd                	addw	a1,a1,a5
    8000303c:	00000097          	auipc	ra,0x0
    80003040:	d9e080e7          	jalr	-610(ra) # 80002dda <bread>
  bi = b % BPB;
  m = 1 << (bi % 8);
    80003044:	0074f713          	andi	a4,s1,7
    80003048:	4785                	li	a5,1
    8000304a:	00e797bb          	sllw	a5,a5,a4
  if((bp->data[bi/8] & m) == 0)
    8000304e:	14ce                	slli	s1,s1,0x33
    80003050:	90d9                	srli	s1,s1,0x36
    80003052:	00950733          	add	a4,a0,s1
    80003056:	05874703          	lbu	a4,88(a4)
    8000305a:	00e7f6b3          	and	a3,a5,a4
    8000305e:	c69d                	beqz	a3,8000308c <bfree+0x6c>
    80003060:	892a                	mv	s2,a0
    panic("freeing free block");
  bp->data[bi/8] &= ~m;
    80003062:	94aa                	add	s1,s1,a0
    80003064:	fff7c793          	not	a5,a5
    80003068:	8f7d                	and	a4,a4,a5
    8000306a:	04e48c23          	sb	a4,88(s1)
  log_write(bp);
    8000306e:	00002097          	auipc	ra,0x2
    80003072:	a00080e7          	jalr	-1536(ra) # 80004a6e <log_write>
  brelse(bp);
    80003076:	854a                	mv	a0,s2
    80003078:	00000097          	auipc	ra,0x0
    8000307c:	e92080e7          	jalr	-366(ra) # 80002f0a <brelse>
}
    80003080:	60e2                	ld	ra,24(sp)
    80003082:	6442                	ld	s0,16(sp)
    80003084:	64a2                	ld	s1,8(sp)
    80003086:	6902                	ld	s2,0(sp)
    80003088:	6105                	addi	sp,sp,32
    8000308a:	8082                	ret
    panic("freeing free block");
    8000308c:	00005517          	auipc	a0,0x5
    80003090:	48c50513          	addi	a0,a0,1164 # 80008518 <syscalls+0xf8>
    80003094:	ffffd097          	auipc	ra,0xffffd
    80003098:	498080e7          	jalr	1176(ra) # 8000052c <panic>

000000008000309c <balloc>:
{
    8000309c:	711d                	addi	sp,sp,-96
    8000309e:	ec86                	sd	ra,88(sp)
    800030a0:	e8a2                	sd	s0,80(sp)
    800030a2:	e4a6                	sd	s1,72(sp)
    800030a4:	e0ca                	sd	s2,64(sp)
    800030a6:	fc4e                	sd	s3,56(sp)
    800030a8:	f852                	sd	s4,48(sp)
    800030aa:	f456                	sd	s5,40(sp)
    800030ac:	f05a                	sd	s6,32(sp)
    800030ae:	ec5e                	sd	s7,24(sp)
    800030b0:	e862                	sd	s8,16(sp)
    800030b2:	e466                	sd	s9,8(sp)
    800030b4:	1080                	addi	s0,sp,96
  for(b = 0; b < sb.size; b += BPB){
    800030b6:	00018797          	auipc	a5,0x18
    800030ba:	aee7a783          	lw	a5,-1298(a5) # 8001aba4 <sb+0x4>
    800030be:	cbc1                	beqz	a5,8000314e <balloc+0xb2>
    800030c0:	8baa                	mv	s7,a0
    800030c2:	4a81                	li	s5,0
    bp = bread(dev, BBLOCK(b, sb));
    800030c4:	00018b17          	auipc	s6,0x18
    800030c8:	adcb0b13          	addi	s6,s6,-1316 # 8001aba0 <sb>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800030cc:	4c01                	li	s8,0
      m = 1 << (bi % 8);
    800030ce:	4985                	li	s3,1
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    800030d0:	6a09                	lui	s4,0x2
  for(b = 0; b < sb.size; b += BPB){
    800030d2:	6c89                	lui	s9,0x2
    800030d4:	a831                	j	800030f0 <balloc+0x54>
    brelse(bp);
    800030d6:	854a                	mv	a0,s2
    800030d8:	00000097          	auipc	ra,0x0
    800030dc:	e32080e7          	jalr	-462(ra) # 80002f0a <brelse>
  for(b = 0; b < sb.size; b += BPB){
    800030e0:	015c87bb          	addw	a5,s9,s5
    800030e4:	00078a9b          	sext.w	s5,a5
    800030e8:	004b2703          	lw	a4,4(s6)
    800030ec:	06eaf163          	bgeu	s5,a4,8000314e <balloc+0xb2>
    bp = bread(dev, BBLOCK(b, sb));
    800030f0:	41fad79b          	sraiw	a5,s5,0x1f
    800030f4:	0137d79b          	srliw	a5,a5,0x13
    800030f8:	015787bb          	addw	a5,a5,s5
    800030fc:	40d7d79b          	sraiw	a5,a5,0xd
    80003100:	01cb2583          	lw	a1,28(s6)
    80003104:	9dbd                	addw	a1,a1,a5
    80003106:	855e                	mv	a0,s7
    80003108:	00000097          	auipc	ra,0x0
    8000310c:	cd2080e7          	jalr	-814(ra) # 80002dda <bread>
    80003110:	892a                	mv	s2,a0
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003112:	004b2503          	lw	a0,4(s6)
    80003116:	000a849b          	sext.w	s1,s5
    8000311a:	8762                	mv	a4,s8
    8000311c:	faa4fde3          	bgeu	s1,a0,800030d6 <balloc+0x3a>
      m = 1 << (bi % 8);
    80003120:	00777693          	andi	a3,a4,7
    80003124:	00d996bb          	sllw	a3,s3,a3
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80003128:	41f7579b          	sraiw	a5,a4,0x1f
    8000312c:	01d7d79b          	srliw	a5,a5,0x1d
    80003130:	9fb9                	addw	a5,a5,a4
    80003132:	4037d79b          	sraiw	a5,a5,0x3
    80003136:	00f90633          	add	a2,s2,a5
    8000313a:	05864603          	lbu	a2,88(a2)
    8000313e:	00c6f5b3          	and	a1,a3,a2
    80003142:	cd91                	beqz	a1,8000315e <balloc+0xc2>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003144:	2705                	addiw	a4,a4,1
    80003146:	2485                	addiw	s1,s1,1
    80003148:	fd471ae3          	bne	a4,s4,8000311c <balloc+0x80>
    8000314c:	b769                	j	800030d6 <balloc+0x3a>
  panic("balloc: out of blocks");
    8000314e:	00005517          	auipc	a0,0x5
    80003152:	3e250513          	addi	a0,a0,994 # 80008530 <syscalls+0x110>
    80003156:	ffffd097          	auipc	ra,0xffffd
    8000315a:	3d6080e7          	jalr	982(ra) # 8000052c <panic>
        bp->data[bi/8] |= m;  // Mark block in use.
    8000315e:	97ca                	add	a5,a5,s2
    80003160:	8e55                	or	a2,a2,a3
    80003162:	04c78c23          	sb	a2,88(a5)
        log_write(bp);
    80003166:	854a                	mv	a0,s2
    80003168:	00002097          	auipc	ra,0x2
    8000316c:	906080e7          	jalr	-1786(ra) # 80004a6e <log_write>
        brelse(bp);
    80003170:	854a                	mv	a0,s2
    80003172:	00000097          	auipc	ra,0x0
    80003176:	d98080e7          	jalr	-616(ra) # 80002f0a <brelse>
  bp = bread(dev, bno);
    8000317a:	85a6                	mv	a1,s1
    8000317c:	855e                	mv	a0,s7
    8000317e:	00000097          	auipc	ra,0x0
    80003182:	c5c080e7          	jalr	-932(ra) # 80002dda <bread>
    80003186:	892a                	mv	s2,a0
  memset(bp->data, 0, BSIZE);
    80003188:	40000613          	li	a2,1024
    8000318c:	4581                	li	a1,0
    8000318e:	05850513          	addi	a0,a0,88
    80003192:	ffffe097          	auipc	ra,0xffffe
    80003196:	b2c080e7          	jalr	-1236(ra) # 80000cbe <memset>
  log_write(bp);
    8000319a:	854a                	mv	a0,s2
    8000319c:	00002097          	auipc	ra,0x2
    800031a0:	8d2080e7          	jalr	-1838(ra) # 80004a6e <log_write>
  brelse(bp);
    800031a4:	854a                	mv	a0,s2
    800031a6:	00000097          	auipc	ra,0x0
    800031aa:	d64080e7          	jalr	-668(ra) # 80002f0a <brelse>
}
    800031ae:	8526                	mv	a0,s1
    800031b0:	60e6                	ld	ra,88(sp)
    800031b2:	6446                	ld	s0,80(sp)
    800031b4:	64a6                	ld	s1,72(sp)
    800031b6:	6906                	ld	s2,64(sp)
    800031b8:	79e2                	ld	s3,56(sp)
    800031ba:	7a42                	ld	s4,48(sp)
    800031bc:	7aa2                	ld	s5,40(sp)
    800031be:	7b02                	ld	s6,32(sp)
    800031c0:	6be2                	ld	s7,24(sp)
    800031c2:	6c42                	ld	s8,16(sp)
    800031c4:	6ca2                	ld	s9,8(sp)
    800031c6:	6125                	addi	sp,sp,96
    800031c8:	8082                	ret

00000000800031ca <bmap>:

// Return the disk block address of the nth block in inode ip.
// If there is no such block, bmap allocates one.
static uint
bmap(struct inode *ip, uint bn)
{
    800031ca:	7139                	addi	sp,sp,-64
    800031cc:	fc06                	sd	ra,56(sp)
    800031ce:	f822                	sd	s0,48(sp)
    800031d0:	f426                	sd	s1,40(sp)
    800031d2:	f04a                	sd	s2,32(sp)
    800031d4:	ec4e                	sd	s3,24(sp)
    800031d6:	e852                	sd	s4,16(sp)
    800031d8:	e456                	sd	s5,8(sp)
    800031da:	0080                	addi	s0,sp,64
    800031dc:	89aa                	mv	s3,a0
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
    800031de:	47a9                	li	a5,10
    800031e0:	08b7fd63          	bgeu	a5,a1,8000327a <bmap+0xb0>
    if((addr = ip->addrs[bn]) == 0)
      ip->addrs[bn] = addr = balloc(ip->dev);
    return addr;
  }
  bn -= NDIRECT;
    800031e4:	ff55849b          	addiw	s1,a1,-11
    800031e8:	0004871b          	sext.w	a4,s1

  if(bn < NINDIRECT){
    800031ec:	0ff00793          	li	a5,255
    800031f0:	0ae7f963          	bgeu	a5,a4,800032a2 <bmap+0xd8>
    }
    brelse(bp);
    return addr;
  }

  bn -= NINDIRECT;
    800031f4:	ef55849b          	addiw	s1,a1,-267
    800031f8:	0004871b          	sext.w	a4,s1
  if(bn < NDINDIRECT){
    800031fc:	67c1                	lui	a5,0x10
    800031fe:	16f77063          	bgeu	a4,a5,8000335e <bmap+0x194>
    // 二级间接索引的处理方法
    // 判断二级间接索引所在的位置是否有效
    if((addr = ip->addrs[NDIRECT + 1]) == 0)
    80003202:	08052583          	lw	a1,128(a0)
    80003206:	10058263          	beqz	a1,8000330a <bmap+0x140>
      // 无效 分配一个空闲块作为二级索引页
      ip->addrs[NDIRECT + 1] = addr = balloc(ip->dev);
    // 使用缓冲区bp读出二级索引页
    bp = bread(ip->dev, addr);
    8000320a:	0009a503          	lw	a0,0(s3)
    8000320e:	00000097          	auipc	ra,0x0
    80003212:	bcc080e7          	jalr	-1076(ra) # 80002dda <bread>
    80003216:	892a                	mv	s2,a0
    a = (uint*)bp->data;
    80003218:	05850a13          	addi	s4,a0,88
    // 判断一级间接索引所在位置是否有效
    if((addr = a[bn / NINDIRECT]) == 0){
    8000321c:	0084d79b          	srliw	a5,s1,0x8
    80003220:	078a                	slli	a5,a5,0x2
    80003222:	9a3e                	add	s4,s4,a5
    80003224:	000a2a83          	lw	s5,0(s4) # 2000 <_entry-0x7fffe000>
    80003228:	0e0a8b63          	beqz	s5,8000331e <bmap+0x154>
      a[bn / NINDIRECT] = addr = balloc(ip->dev);
      // 将修改后的buf写入日志
      log_write(bp);
    }
    // 释放buf缓冲区
    brelse(bp);
    8000322c:	854a                	mv	a0,s2
    8000322e:	00000097          	auipc	ra,0x0
    80003232:	cdc080e7          	jalr	-804(ra) # 80002f0a <brelse>
    // 使用缓冲区bp读出一级索引页
    bp = bread(ip->dev, addr);
    80003236:	85d6                	mv	a1,s5
    80003238:	0009a503          	lw	a0,0(s3)
    8000323c:	00000097          	auipc	ra,0x0
    80003240:	b9e080e7          	jalr	-1122(ra) # 80002dda <bread>
    80003244:	8a2a                	mv	s4,a0
    a = (uint*)bp->data;
    80003246:	05850793          	addi	a5,a0,88
    // 判断直接索引所在位置是否有效
    if((addr = a[bn % NINDIRECT]) == 0){
    8000324a:	0ff4f593          	zext.b	a1,s1
    8000324e:	058a                	slli	a1,a1,0x2
    80003250:	00b784b3          	add	s1,a5,a1
    80003254:	0004a903          	lw	s2,0(s1)
    80003258:	0e090363          	beqz	s2,8000333e <bmap+0x174>
      a[bn % NINDIRECT] = addr = balloc(ip->dev);
      // 将修改后的buf写入日志
      log_write(bp);
    }
    // 释放buf缓冲区
    brelse(bp);
    8000325c:	8552                	mv	a0,s4
    8000325e:	00000097          	auipc	ra,0x0
    80003262:	cac080e7          	jalr	-852(ra) # 80002f0a <brelse>
    // 返回找到的地址
    return addr;
  }

  panic("bmap: out of range");
}
    80003266:	854a                	mv	a0,s2
    80003268:	70e2                	ld	ra,56(sp)
    8000326a:	7442                	ld	s0,48(sp)
    8000326c:	74a2                	ld	s1,40(sp)
    8000326e:	7902                	ld	s2,32(sp)
    80003270:	69e2                	ld	s3,24(sp)
    80003272:	6a42                	ld	s4,16(sp)
    80003274:	6aa2                	ld	s5,8(sp)
    80003276:	6121                	addi	sp,sp,64
    80003278:	8082                	ret
    if((addr = ip->addrs[bn]) == 0)
    8000327a:	02059793          	slli	a5,a1,0x20
    8000327e:	01e7d593          	srli	a1,a5,0x1e
    80003282:	00b504b3          	add	s1,a0,a1
    80003286:	0504a903          	lw	s2,80(s1)
    8000328a:	fc091ee3          	bnez	s2,80003266 <bmap+0x9c>
      ip->addrs[bn] = addr = balloc(ip->dev);
    8000328e:	4108                	lw	a0,0(a0)
    80003290:	00000097          	auipc	ra,0x0
    80003294:	e0c080e7          	jalr	-500(ra) # 8000309c <balloc>
    80003298:	0005091b          	sext.w	s2,a0
    8000329c:	0524a823          	sw	s2,80(s1)
    800032a0:	b7d9                	j	80003266 <bmap+0x9c>
    if((addr = ip->addrs[NDIRECT]) == 0)
    800032a2:	5d6c                	lw	a1,124(a0)
    800032a4:	c98d                	beqz	a1,800032d6 <bmap+0x10c>
    bp = bread(ip->dev, addr);
    800032a6:	0009a503          	lw	a0,0(s3)
    800032aa:	00000097          	auipc	ra,0x0
    800032ae:	b30080e7          	jalr	-1232(ra) # 80002dda <bread>
    800032b2:	8a2a                	mv	s4,a0
    a = (uint*)bp->data;
    800032b4:	05850793          	addi	a5,a0,88
    if((addr = a[bn]) == 0){
    800032b8:	02049713          	slli	a4,s1,0x20
    800032bc:	01e75493          	srli	s1,a4,0x1e
    800032c0:	94be                	add	s1,s1,a5
    800032c2:	0004a903          	lw	s2,0(s1)
    800032c6:	02090263          	beqz	s2,800032ea <bmap+0x120>
    brelse(bp);
    800032ca:	8552                	mv	a0,s4
    800032cc:	00000097          	auipc	ra,0x0
    800032d0:	c3e080e7          	jalr	-962(ra) # 80002f0a <brelse>
    return addr;
    800032d4:	bf49                	j	80003266 <bmap+0x9c>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    800032d6:	4108                	lw	a0,0(a0)
    800032d8:	00000097          	auipc	ra,0x0
    800032dc:	dc4080e7          	jalr	-572(ra) # 8000309c <balloc>
    800032e0:	0005059b          	sext.w	a1,a0
    800032e4:	06b9ae23          	sw	a1,124(s3)
    800032e8:	bf7d                	j	800032a6 <bmap+0xdc>
      a[bn] = addr = balloc(ip->dev);
    800032ea:	0009a503          	lw	a0,0(s3)
    800032ee:	00000097          	auipc	ra,0x0
    800032f2:	dae080e7          	jalr	-594(ra) # 8000309c <balloc>
    800032f6:	0005091b          	sext.w	s2,a0
    800032fa:	0124a023          	sw	s2,0(s1)
      log_write(bp);
    800032fe:	8552                	mv	a0,s4
    80003300:	00001097          	auipc	ra,0x1
    80003304:	76e080e7          	jalr	1902(ra) # 80004a6e <log_write>
    80003308:	b7c9                	j	800032ca <bmap+0x100>
      ip->addrs[NDIRECT + 1] = addr = balloc(ip->dev);
    8000330a:	4108                	lw	a0,0(a0)
    8000330c:	00000097          	auipc	ra,0x0
    80003310:	d90080e7          	jalr	-624(ra) # 8000309c <balloc>
    80003314:	0005059b          	sext.w	a1,a0
    80003318:	08b9a023          	sw	a1,128(s3)
    8000331c:	b5fd                	j	8000320a <bmap+0x40>
      a[bn / NINDIRECT] = addr = balloc(ip->dev);
    8000331e:	0009a503          	lw	a0,0(s3)
    80003322:	00000097          	auipc	ra,0x0
    80003326:	d7a080e7          	jalr	-646(ra) # 8000309c <balloc>
    8000332a:	00050a9b          	sext.w	s5,a0
    8000332e:	015a2023          	sw	s5,0(s4)
      log_write(bp);
    80003332:	854a                	mv	a0,s2
    80003334:	00001097          	auipc	ra,0x1
    80003338:	73a080e7          	jalr	1850(ra) # 80004a6e <log_write>
    8000333c:	bdc5                	j	8000322c <bmap+0x62>
      a[bn % NINDIRECT] = addr = balloc(ip->dev);
    8000333e:	0009a503          	lw	a0,0(s3)
    80003342:	00000097          	auipc	ra,0x0
    80003346:	d5a080e7          	jalr	-678(ra) # 8000309c <balloc>
    8000334a:	0005091b          	sext.w	s2,a0
    8000334e:	0124a023          	sw	s2,0(s1)
      log_write(bp);
    80003352:	8552                	mv	a0,s4
    80003354:	00001097          	auipc	ra,0x1
    80003358:	71a080e7          	jalr	1818(ra) # 80004a6e <log_write>
    8000335c:	b701                	j	8000325c <bmap+0x92>
  panic("bmap: out of range");
    8000335e:	00005517          	auipc	a0,0x5
    80003362:	1ea50513          	addi	a0,a0,490 # 80008548 <syscalls+0x128>
    80003366:	ffffd097          	auipc	ra,0xffffd
    8000336a:	1c6080e7          	jalr	454(ra) # 8000052c <panic>

000000008000336e <iget>:
{
    8000336e:	7179                	addi	sp,sp,-48
    80003370:	f406                	sd	ra,40(sp)
    80003372:	f022                	sd	s0,32(sp)
    80003374:	ec26                	sd	s1,24(sp)
    80003376:	e84a                	sd	s2,16(sp)
    80003378:	e44e                	sd	s3,8(sp)
    8000337a:	e052                	sd	s4,0(sp)
    8000337c:	1800                	addi	s0,sp,48
    8000337e:	89aa                	mv	s3,a0
    80003380:	8a2e                	mv	s4,a1
  acquire(&icache.lock);
    80003382:	00018517          	auipc	a0,0x18
    80003386:	83e50513          	addi	a0,a0,-1986 # 8001abc0 <icache>
    8000338a:	ffffe097          	auipc	ra,0xffffe
    8000338e:	838080e7          	jalr	-1992(ra) # 80000bc2 <acquire>
  empty = 0;
    80003392:	4901                	li	s2,0
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    80003394:	00018497          	auipc	s1,0x18
    80003398:	84448493          	addi	s1,s1,-1980 # 8001abd8 <icache+0x18>
    8000339c:	00019697          	auipc	a3,0x19
    800033a0:	2cc68693          	addi	a3,a3,716 # 8001c668 <log>
    800033a4:	a039                	j	800033b2 <iget+0x44>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    800033a6:	02090b63          	beqz	s2,800033dc <iget+0x6e>
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    800033aa:	08848493          	addi	s1,s1,136
    800033ae:	02d48a63          	beq	s1,a3,800033e2 <iget+0x74>
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
    800033b2:	449c                	lw	a5,8(s1)
    800033b4:	fef059e3          	blez	a5,800033a6 <iget+0x38>
    800033b8:	4098                	lw	a4,0(s1)
    800033ba:	ff3716e3          	bne	a4,s3,800033a6 <iget+0x38>
    800033be:	40d8                	lw	a4,4(s1)
    800033c0:	ff4713e3          	bne	a4,s4,800033a6 <iget+0x38>
      ip->ref++;
    800033c4:	2785                	addiw	a5,a5,1 # 10001 <_entry-0x7ffeffff>
    800033c6:	c49c                	sw	a5,8(s1)
      release(&icache.lock);
    800033c8:	00017517          	auipc	a0,0x17
    800033cc:	7f850513          	addi	a0,a0,2040 # 8001abc0 <icache>
    800033d0:	ffffe097          	auipc	ra,0xffffe
    800033d4:	8a6080e7          	jalr	-1882(ra) # 80000c76 <release>
      return ip;
    800033d8:	8926                	mv	s2,s1
    800033da:	a03d                	j	80003408 <iget+0x9a>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    800033dc:	f7f9                	bnez	a5,800033aa <iget+0x3c>
    800033de:	8926                	mv	s2,s1
    800033e0:	b7e9                	j	800033aa <iget+0x3c>
  if(empty == 0)
    800033e2:	02090c63          	beqz	s2,8000341a <iget+0xac>
  ip->dev = dev;
    800033e6:	01392023          	sw	s3,0(s2)
  ip->inum = inum;
    800033ea:	01492223          	sw	s4,4(s2)
  ip->ref = 1;
    800033ee:	4785                	li	a5,1
    800033f0:	00f92423          	sw	a5,8(s2)
  ip->valid = 0;
    800033f4:	04092023          	sw	zero,64(s2)
  release(&icache.lock);
    800033f8:	00017517          	auipc	a0,0x17
    800033fc:	7c850513          	addi	a0,a0,1992 # 8001abc0 <icache>
    80003400:	ffffe097          	auipc	ra,0xffffe
    80003404:	876080e7          	jalr	-1930(ra) # 80000c76 <release>
}
    80003408:	854a                	mv	a0,s2
    8000340a:	70a2                	ld	ra,40(sp)
    8000340c:	7402                	ld	s0,32(sp)
    8000340e:	64e2                	ld	s1,24(sp)
    80003410:	6942                	ld	s2,16(sp)
    80003412:	69a2                	ld	s3,8(sp)
    80003414:	6a02                	ld	s4,0(sp)
    80003416:	6145                	addi	sp,sp,48
    80003418:	8082                	ret
    panic("iget: no inodes");
    8000341a:	00005517          	auipc	a0,0x5
    8000341e:	14650513          	addi	a0,a0,326 # 80008560 <syscalls+0x140>
    80003422:	ffffd097          	auipc	ra,0xffffd
    80003426:	10a080e7          	jalr	266(ra) # 8000052c <panic>

000000008000342a <fsinit>:
fsinit(int dev) {
    8000342a:	7179                	addi	sp,sp,-48
    8000342c:	f406                	sd	ra,40(sp)
    8000342e:	f022                	sd	s0,32(sp)
    80003430:	ec26                	sd	s1,24(sp)
    80003432:	e84a                	sd	s2,16(sp)
    80003434:	e44e                	sd	s3,8(sp)
    80003436:	1800                	addi	s0,sp,48
    80003438:	892a                	mv	s2,a0
  bp = bread(dev, 1);
    8000343a:	4585                	li	a1,1
    8000343c:	00000097          	auipc	ra,0x0
    80003440:	99e080e7          	jalr	-1634(ra) # 80002dda <bread>
    80003444:	84aa                	mv	s1,a0
  memmove(sb, bp->data, sizeof(*sb));
    80003446:	00017997          	auipc	s3,0x17
    8000344a:	75a98993          	addi	s3,s3,1882 # 8001aba0 <sb>
    8000344e:	02000613          	li	a2,32
    80003452:	05850593          	addi	a1,a0,88
    80003456:	854e                	mv	a0,s3
    80003458:	ffffe097          	auipc	ra,0xffffe
    8000345c:	8c2080e7          	jalr	-1854(ra) # 80000d1a <memmove>
  brelse(bp);
    80003460:	8526                	mv	a0,s1
    80003462:	00000097          	auipc	ra,0x0
    80003466:	aa8080e7          	jalr	-1368(ra) # 80002f0a <brelse>
  if(sb.magic != FSMAGIC)
    8000346a:	0009a703          	lw	a4,0(s3)
    8000346e:	102037b7          	lui	a5,0x10203
    80003472:	04078793          	addi	a5,a5,64 # 10203040 <_entry-0x6fdfcfc0>
    80003476:	02f71263          	bne	a4,a5,8000349a <fsinit+0x70>
  initlog(dev, &sb);
    8000347a:	00017597          	auipc	a1,0x17
    8000347e:	72658593          	addi	a1,a1,1830 # 8001aba0 <sb>
    80003482:	854a                	mv	a0,s2
    80003484:	00001097          	auipc	ra,0x1
    80003488:	36e080e7          	jalr	878(ra) # 800047f2 <initlog>
}
    8000348c:	70a2                	ld	ra,40(sp)
    8000348e:	7402                	ld	s0,32(sp)
    80003490:	64e2                	ld	s1,24(sp)
    80003492:	6942                	ld	s2,16(sp)
    80003494:	69a2                	ld	s3,8(sp)
    80003496:	6145                	addi	sp,sp,48
    80003498:	8082                	ret
    panic("invalid file system");
    8000349a:	00005517          	auipc	a0,0x5
    8000349e:	0d650513          	addi	a0,a0,214 # 80008570 <syscalls+0x150>
    800034a2:	ffffd097          	auipc	ra,0xffffd
    800034a6:	08a080e7          	jalr	138(ra) # 8000052c <panic>

00000000800034aa <iinit>:
{
    800034aa:	7179                	addi	sp,sp,-48
    800034ac:	f406                	sd	ra,40(sp)
    800034ae:	f022                	sd	s0,32(sp)
    800034b0:	ec26                	sd	s1,24(sp)
    800034b2:	e84a                	sd	s2,16(sp)
    800034b4:	e44e                	sd	s3,8(sp)
    800034b6:	1800                	addi	s0,sp,48
  initlock(&icache.lock, "icache");
    800034b8:	00005597          	auipc	a1,0x5
    800034bc:	0d058593          	addi	a1,a1,208 # 80008588 <syscalls+0x168>
    800034c0:	00017517          	auipc	a0,0x17
    800034c4:	70050513          	addi	a0,a0,1792 # 8001abc0 <icache>
    800034c8:	ffffd097          	auipc	ra,0xffffd
    800034cc:	66a080e7          	jalr	1642(ra) # 80000b32 <initlock>
  for(i = 0; i < NINODE; i++) {
    800034d0:	00017497          	auipc	s1,0x17
    800034d4:	71848493          	addi	s1,s1,1816 # 8001abe8 <icache+0x28>
    800034d8:	00019997          	auipc	s3,0x19
    800034dc:	1a098993          	addi	s3,s3,416 # 8001c678 <log+0x10>
    initsleeplock(&icache.inode[i].lock, "inode");
    800034e0:	00005917          	auipc	s2,0x5
    800034e4:	0b090913          	addi	s2,s2,176 # 80008590 <syscalls+0x170>
    800034e8:	85ca                	mv	a1,s2
    800034ea:	8526                	mv	a0,s1
    800034ec:	00001097          	auipc	ra,0x1
    800034f0:	66e080e7          	jalr	1646(ra) # 80004b5a <initsleeplock>
  for(i = 0; i < NINODE; i++) {
    800034f4:	08848493          	addi	s1,s1,136
    800034f8:	ff3498e3          	bne	s1,s3,800034e8 <iinit+0x3e>
}
    800034fc:	70a2                	ld	ra,40(sp)
    800034fe:	7402                	ld	s0,32(sp)
    80003500:	64e2                	ld	s1,24(sp)
    80003502:	6942                	ld	s2,16(sp)
    80003504:	69a2                	ld	s3,8(sp)
    80003506:	6145                	addi	sp,sp,48
    80003508:	8082                	ret

000000008000350a <ialloc>:
{
    8000350a:	715d                	addi	sp,sp,-80
    8000350c:	e486                	sd	ra,72(sp)
    8000350e:	e0a2                	sd	s0,64(sp)
    80003510:	fc26                	sd	s1,56(sp)
    80003512:	f84a                	sd	s2,48(sp)
    80003514:	f44e                	sd	s3,40(sp)
    80003516:	f052                	sd	s4,32(sp)
    80003518:	ec56                	sd	s5,24(sp)
    8000351a:	e85a                	sd	s6,16(sp)
    8000351c:	e45e                	sd	s7,8(sp)
    8000351e:	0880                	addi	s0,sp,80
  for(inum = 1; inum < sb.ninodes; inum++){
    80003520:	00017717          	auipc	a4,0x17
    80003524:	68c72703          	lw	a4,1676(a4) # 8001abac <sb+0xc>
    80003528:	4785                	li	a5,1
    8000352a:	04e7fa63          	bgeu	a5,a4,8000357e <ialloc+0x74>
    8000352e:	8aaa                	mv	s5,a0
    80003530:	8bae                	mv	s7,a1
    80003532:	4485                	li	s1,1
    bp = bread(dev, IBLOCK(inum, sb));
    80003534:	00017a17          	auipc	s4,0x17
    80003538:	66ca0a13          	addi	s4,s4,1644 # 8001aba0 <sb>
    8000353c:	00048b1b          	sext.w	s6,s1
    80003540:	0044d593          	srli	a1,s1,0x4
    80003544:	018a2783          	lw	a5,24(s4)
    80003548:	9dbd                	addw	a1,a1,a5
    8000354a:	8556                	mv	a0,s5
    8000354c:	00000097          	auipc	ra,0x0
    80003550:	88e080e7          	jalr	-1906(ra) # 80002dda <bread>
    80003554:	892a                	mv	s2,a0
    dip = (struct dinode*)bp->data + inum%IPB;
    80003556:	05850993          	addi	s3,a0,88
    8000355a:	00f4f793          	andi	a5,s1,15
    8000355e:	079a                	slli	a5,a5,0x6
    80003560:	99be                	add	s3,s3,a5
    if(dip->type == 0){  // a free inode
    80003562:	00099783          	lh	a5,0(s3)
    80003566:	c785                	beqz	a5,8000358e <ialloc+0x84>
    brelse(bp);
    80003568:	00000097          	auipc	ra,0x0
    8000356c:	9a2080e7          	jalr	-1630(ra) # 80002f0a <brelse>
  for(inum = 1; inum < sb.ninodes; inum++){
    80003570:	0485                	addi	s1,s1,1
    80003572:	00ca2703          	lw	a4,12(s4)
    80003576:	0004879b          	sext.w	a5,s1
    8000357a:	fce7e1e3          	bltu	a5,a4,8000353c <ialloc+0x32>
  panic("ialloc: no inodes");
    8000357e:	00005517          	auipc	a0,0x5
    80003582:	01a50513          	addi	a0,a0,26 # 80008598 <syscalls+0x178>
    80003586:	ffffd097          	auipc	ra,0xffffd
    8000358a:	fa6080e7          	jalr	-90(ra) # 8000052c <panic>
      memset(dip, 0, sizeof(*dip));
    8000358e:	04000613          	li	a2,64
    80003592:	4581                	li	a1,0
    80003594:	854e                	mv	a0,s3
    80003596:	ffffd097          	auipc	ra,0xffffd
    8000359a:	728080e7          	jalr	1832(ra) # 80000cbe <memset>
      dip->type = type;
    8000359e:	01799023          	sh	s7,0(s3)
      log_write(bp);   // mark it allocated on the disk
    800035a2:	854a                	mv	a0,s2
    800035a4:	00001097          	auipc	ra,0x1
    800035a8:	4ca080e7          	jalr	1226(ra) # 80004a6e <log_write>
      brelse(bp);
    800035ac:	854a                	mv	a0,s2
    800035ae:	00000097          	auipc	ra,0x0
    800035b2:	95c080e7          	jalr	-1700(ra) # 80002f0a <brelse>
      return iget(dev, inum);
    800035b6:	85da                	mv	a1,s6
    800035b8:	8556                	mv	a0,s5
    800035ba:	00000097          	auipc	ra,0x0
    800035be:	db4080e7          	jalr	-588(ra) # 8000336e <iget>
}
    800035c2:	60a6                	ld	ra,72(sp)
    800035c4:	6406                	ld	s0,64(sp)
    800035c6:	74e2                	ld	s1,56(sp)
    800035c8:	7942                	ld	s2,48(sp)
    800035ca:	79a2                	ld	s3,40(sp)
    800035cc:	7a02                	ld	s4,32(sp)
    800035ce:	6ae2                	ld	s5,24(sp)
    800035d0:	6b42                	ld	s6,16(sp)
    800035d2:	6ba2                	ld	s7,8(sp)
    800035d4:	6161                	addi	sp,sp,80
    800035d6:	8082                	ret

00000000800035d8 <iupdate>:
{
    800035d8:	1101                	addi	sp,sp,-32
    800035da:	ec06                	sd	ra,24(sp)
    800035dc:	e822                	sd	s0,16(sp)
    800035de:	e426                	sd	s1,8(sp)
    800035e0:	e04a                	sd	s2,0(sp)
    800035e2:	1000                	addi	s0,sp,32
    800035e4:	84aa                	mv	s1,a0
  bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    800035e6:	415c                	lw	a5,4(a0)
    800035e8:	0047d79b          	srliw	a5,a5,0x4
    800035ec:	00017597          	auipc	a1,0x17
    800035f0:	5cc5a583          	lw	a1,1484(a1) # 8001abb8 <sb+0x18>
    800035f4:	9dbd                	addw	a1,a1,a5
    800035f6:	4108                	lw	a0,0(a0)
    800035f8:	fffff097          	auipc	ra,0xfffff
    800035fc:	7e2080e7          	jalr	2018(ra) # 80002dda <bread>
    80003600:	892a                	mv	s2,a0
  dip = (struct dinode*)bp->data + ip->inum%IPB;
    80003602:	05850793          	addi	a5,a0,88
    80003606:	40d8                	lw	a4,4(s1)
    80003608:	8b3d                	andi	a4,a4,15
    8000360a:	071a                	slli	a4,a4,0x6
    8000360c:	97ba                	add	a5,a5,a4
  dip->type = ip->type;
    8000360e:	04449703          	lh	a4,68(s1)
    80003612:	00e79023          	sh	a4,0(a5)
  dip->major = ip->major;
    80003616:	04649703          	lh	a4,70(s1)
    8000361a:	00e79123          	sh	a4,2(a5)
  dip->minor = ip->minor;
    8000361e:	04849703          	lh	a4,72(s1)
    80003622:	00e79223          	sh	a4,4(a5)
  dip->nlink = ip->nlink;
    80003626:	04a49703          	lh	a4,74(s1)
    8000362a:	00e79323          	sh	a4,6(a5)
  dip->size = ip->size;
    8000362e:	44f8                	lw	a4,76(s1)
    80003630:	c798                	sw	a4,8(a5)
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
    80003632:	03400613          	li	a2,52
    80003636:	05048593          	addi	a1,s1,80
    8000363a:	00c78513          	addi	a0,a5,12
    8000363e:	ffffd097          	auipc	ra,0xffffd
    80003642:	6dc080e7          	jalr	1756(ra) # 80000d1a <memmove>
  log_write(bp);
    80003646:	854a                	mv	a0,s2
    80003648:	00001097          	auipc	ra,0x1
    8000364c:	426080e7          	jalr	1062(ra) # 80004a6e <log_write>
  brelse(bp);
    80003650:	854a                	mv	a0,s2
    80003652:	00000097          	auipc	ra,0x0
    80003656:	8b8080e7          	jalr	-1864(ra) # 80002f0a <brelse>
}
    8000365a:	60e2                	ld	ra,24(sp)
    8000365c:	6442                	ld	s0,16(sp)
    8000365e:	64a2                	ld	s1,8(sp)
    80003660:	6902                	ld	s2,0(sp)
    80003662:	6105                	addi	sp,sp,32
    80003664:	8082                	ret

0000000080003666 <idup>:
{
    80003666:	1101                	addi	sp,sp,-32
    80003668:	ec06                	sd	ra,24(sp)
    8000366a:	e822                	sd	s0,16(sp)
    8000366c:	e426                	sd	s1,8(sp)
    8000366e:	1000                	addi	s0,sp,32
    80003670:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    80003672:	00017517          	auipc	a0,0x17
    80003676:	54e50513          	addi	a0,a0,1358 # 8001abc0 <icache>
    8000367a:	ffffd097          	auipc	ra,0xffffd
    8000367e:	548080e7          	jalr	1352(ra) # 80000bc2 <acquire>
  ip->ref++;
    80003682:	449c                	lw	a5,8(s1)
    80003684:	2785                	addiw	a5,a5,1
    80003686:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    80003688:	00017517          	auipc	a0,0x17
    8000368c:	53850513          	addi	a0,a0,1336 # 8001abc0 <icache>
    80003690:	ffffd097          	auipc	ra,0xffffd
    80003694:	5e6080e7          	jalr	1510(ra) # 80000c76 <release>
}
    80003698:	8526                	mv	a0,s1
    8000369a:	60e2                	ld	ra,24(sp)
    8000369c:	6442                	ld	s0,16(sp)
    8000369e:	64a2                	ld	s1,8(sp)
    800036a0:	6105                	addi	sp,sp,32
    800036a2:	8082                	ret

00000000800036a4 <ilock>:
{
    800036a4:	1101                	addi	sp,sp,-32
    800036a6:	ec06                	sd	ra,24(sp)
    800036a8:	e822                	sd	s0,16(sp)
    800036aa:	e426                	sd	s1,8(sp)
    800036ac:	e04a                	sd	s2,0(sp)
    800036ae:	1000                	addi	s0,sp,32
  if(ip == 0 || ip->ref < 1)
    800036b0:	c115                	beqz	a0,800036d4 <ilock+0x30>
    800036b2:	84aa                	mv	s1,a0
    800036b4:	451c                	lw	a5,8(a0)
    800036b6:	00f05f63          	blez	a5,800036d4 <ilock+0x30>
  acquiresleep(&ip->lock);
    800036ba:	0541                	addi	a0,a0,16
    800036bc:	00001097          	auipc	ra,0x1
    800036c0:	4d8080e7          	jalr	1240(ra) # 80004b94 <acquiresleep>
  if(ip->valid == 0){
    800036c4:	40bc                	lw	a5,64(s1)
    800036c6:	cf99                	beqz	a5,800036e4 <ilock+0x40>
}
    800036c8:	60e2                	ld	ra,24(sp)
    800036ca:	6442                	ld	s0,16(sp)
    800036cc:	64a2                	ld	s1,8(sp)
    800036ce:	6902                	ld	s2,0(sp)
    800036d0:	6105                	addi	sp,sp,32
    800036d2:	8082                	ret
    panic("ilock");
    800036d4:	00005517          	auipc	a0,0x5
    800036d8:	edc50513          	addi	a0,a0,-292 # 800085b0 <syscalls+0x190>
    800036dc:	ffffd097          	auipc	ra,0xffffd
    800036e0:	e50080e7          	jalr	-432(ra) # 8000052c <panic>
    bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    800036e4:	40dc                	lw	a5,4(s1)
    800036e6:	0047d79b          	srliw	a5,a5,0x4
    800036ea:	00017597          	auipc	a1,0x17
    800036ee:	4ce5a583          	lw	a1,1230(a1) # 8001abb8 <sb+0x18>
    800036f2:	9dbd                	addw	a1,a1,a5
    800036f4:	4088                	lw	a0,0(s1)
    800036f6:	fffff097          	auipc	ra,0xfffff
    800036fa:	6e4080e7          	jalr	1764(ra) # 80002dda <bread>
    800036fe:	892a                	mv	s2,a0
    dip = (struct dinode*)bp->data + ip->inum%IPB;
    80003700:	05850593          	addi	a1,a0,88
    80003704:	40dc                	lw	a5,4(s1)
    80003706:	8bbd                	andi	a5,a5,15
    80003708:	079a                	slli	a5,a5,0x6
    8000370a:	95be                	add	a1,a1,a5
    ip->type = dip->type;
    8000370c:	00059783          	lh	a5,0(a1)
    80003710:	04f49223          	sh	a5,68(s1)
    ip->major = dip->major;
    80003714:	00259783          	lh	a5,2(a1)
    80003718:	04f49323          	sh	a5,70(s1)
    ip->minor = dip->minor;
    8000371c:	00459783          	lh	a5,4(a1)
    80003720:	04f49423          	sh	a5,72(s1)
    ip->nlink = dip->nlink;
    80003724:	00659783          	lh	a5,6(a1)
    80003728:	04f49523          	sh	a5,74(s1)
    ip->size = dip->size;
    8000372c:	459c                	lw	a5,8(a1)
    8000372e:	c4fc                	sw	a5,76(s1)
    memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
    80003730:	03400613          	li	a2,52
    80003734:	05b1                	addi	a1,a1,12
    80003736:	05048513          	addi	a0,s1,80
    8000373a:	ffffd097          	auipc	ra,0xffffd
    8000373e:	5e0080e7          	jalr	1504(ra) # 80000d1a <memmove>
    brelse(bp);
    80003742:	854a                	mv	a0,s2
    80003744:	fffff097          	auipc	ra,0xfffff
    80003748:	7c6080e7          	jalr	1990(ra) # 80002f0a <brelse>
    ip->valid = 1;
    8000374c:	4785                	li	a5,1
    8000374e:	c0bc                	sw	a5,64(s1)
    if(ip->type == 0)
    80003750:	04449783          	lh	a5,68(s1)
    80003754:	fbb5                	bnez	a5,800036c8 <ilock+0x24>
      panic("ilock: no type");
    80003756:	00005517          	auipc	a0,0x5
    8000375a:	e6250513          	addi	a0,a0,-414 # 800085b8 <syscalls+0x198>
    8000375e:	ffffd097          	auipc	ra,0xffffd
    80003762:	dce080e7          	jalr	-562(ra) # 8000052c <panic>

0000000080003766 <iunlock>:
{
    80003766:	1101                	addi	sp,sp,-32
    80003768:	ec06                	sd	ra,24(sp)
    8000376a:	e822                	sd	s0,16(sp)
    8000376c:	e426                	sd	s1,8(sp)
    8000376e:	e04a                	sd	s2,0(sp)
    80003770:	1000                	addi	s0,sp,32
  if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1)
    80003772:	c905                	beqz	a0,800037a2 <iunlock+0x3c>
    80003774:	84aa                	mv	s1,a0
    80003776:	01050913          	addi	s2,a0,16
    8000377a:	854a                	mv	a0,s2
    8000377c:	00001097          	auipc	ra,0x1
    80003780:	4b2080e7          	jalr	1202(ra) # 80004c2e <holdingsleep>
    80003784:	cd19                	beqz	a0,800037a2 <iunlock+0x3c>
    80003786:	449c                	lw	a5,8(s1)
    80003788:	00f05d63          	blez	a5,800037a2 <iunlock+0x3c>
  releasesleep(&ip->lock);
    8000378c:	854a                	mv	a0,s2
    8000378e:	00001097          	auipc	ra,0x1
    80003792:	45c080e7          	jalr	1116(ra) # 80004bea <releasesleep>
}
    80003796:	60e2                	ld	ra,24(sp)
    80003798:	6442                	ld	s0,16(sp)
    8000379a:	64a2                	ld	s1,8(sp)
    8000379c:	6902                	ld	s2,0(sp)
    8000379e:	6105                	addi	sp,sp,32
    800037a0:	8082                	ret
    panic("iunlock");
    800037a2:	00005517          	auipc	a0,0x5
    800037a6:	e2650513          	addi	a0,a0,-474 # 800085c8 <syscalls+0x1a8>
    800037aa:	ffffd097          	auipc	ra,0xffffd
    800037ae:	d82080e7          	jalr	-638(ra) # 8000052c <panic>

00000000800037b2 <itrunc>:

// Truncate inode (discard contents).
// Caller must hold ip->lock.
void
itrunc(struct inode *ip)
{
    800037b2:	715d                	addi	sp,sp,-80
    800037b4:	e486                	sd	ra,72(sp)
    800037b6:	e0a2                	sd	s0,64(sp)
    800037b8:	fc26                	sd	s1,56(sp)
    800037ba:	f84a                	sd	s2,48(sp)
    800037bc:	f44e                	sd	s3,40(sp)
    800037be:	f052                	sd	s4,32(sp)
    800037c0:	ec56                	sd	s5,24(sp)
    800037c2:	e85a                	sd	s6,16(sp)
    800037c4:	e45e                	sd	s7,8(sp)
    800037c6:	e062                	sd	s8,0(sp)
    800037c8:	0880                	addi	s0,sp,80
    800037ca:	89aa                	mv	s3,a0
  int i, j;
  struct buf *bp;
  uint *a;

  for(i = 0; i < NDIRECT; i++){
    800037cc:	05050493          	addi	s1,a0,80
    800037d0:	07c50913          	addi	s2,a0,124
    800037d4:	a021                	j	800037dc <itrunc+0x2a>
    800037d6:	0491                	addi	s1,s1,4
    800037d8:	01248d63          	beq	s1,s2,800037f2 <itrunc+0x40>
    if(ip->addrs[i]){
    800037dc:	408c                	lw	a1,0(s1)
    800037de:	dde5                	beqz	a1,800037d6 <itrunc+0x24>
      bfree(ip->dev, ip->addrs[i]);
    800037e0:	0009a503          	lw	a0,0(s3)
    800037e4:	00000097          	auipc	ra,0x0
    800037e8:	83c080e7          	jalr	-1988(ra) # 80003020 <bfree>
      ip->addrs[i] = 0;
    800037ec:	0004a023          	sw	zero,0(s1)
    800037f0:	b7dd                	j	800037d6 <itrunc+0x24>
    }
  }

  if(ip->addrs[NDIRECT]){
    800037f2:	07c9a583          	lw	a1,124(s3)
    800037f6:	e59d                	bnez	a1,80003824 <itrunc+0x72>
    bfree(ip->dev, ip->addrs[NDIRECT]);
    ip->addrs[NDIRECT] = 0;
  }

  // 二级间接索引是否有效
  if(ip->addrs[NDIRECT+1]){
    800037f8:	0809a583          	lw	a1,128(s3)
    800037fc:	eda5                	bnez	a1,80003874 <itrunc+0xc2>
    brelse(bp);
    bfree(ip->dev, ip->addrs[NDIRECT + 1]);
    ip->addrs[NDIRECT + 1] = 0;
  }

  ip->size = 0;
    800037fe:	0409a623          	sw	zero,76(s3)
  iupdate(ip);
    80003802:	854e                	mv	a0,s3
    80003804:	00000097          	auipc	ra,0x0
    80003808:	dd4080e7          	jalr	-556(ra) # 800035d8 <iupdate>
}
    8000380c:	60a6                	ld	ra,72(sp)
    8000380e:	6406                	ld	s0,64(sp)
    80003810:	74e2                	ld	s1,56(sp)
    80003812:	7942                	ld	s2,48(sp)
    80003814:	79a2                	ld	s3,40(sp)
    80003816:	7a02                	ld	s4,32(sp)
    80003818:	6ae2                	ld	s5,24(sp)
    8000381a:	6b42                	ld	s6,16(sp)
    8000381c:	6ba2                	ld	s7,8(sp)
    8000381e:	6c02                	ld	s8,0(sp)
    80003820:	6161                	addi	sp,sp,80
    80003822:	8082                	ret
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
    80003824:	0009a503          	lw	a0,0(s3)
    80003828:	fffff097          	auipc	ra,0xfffff
    8000382c:	5b2080e7          	jalr	1458(ra) # 80002dda <bread>
    80003830:	8a2a                	mv	s4,a0
    for(j = 0; j < NINDIRECT; j++){
    80003832:	05850493          	addi	s1,a0,88
    80003836:	45850913          	addi	s2,a0,1112
    8000383a:	a021                	j	80003842 <itrunc+0x90>
    8000383c:	0491                	addi	s1,s1,4
    8000383e:	01248b63          	beq	s1,s2,80003854 <itrunc+0xa2>
      if(a[j])
    80003842:	408c                	lw	a1,0(s1)
    80003844:	dde5                	beqz	a1,8000383c <itrunc+0x8a>
        bfree(ip->dev, a[j]);
    80003846:	0009a503          	lw	a0,0(s3)
    8000384a:	fffff097          	auipc	ra,0xfffff
    8000384e:	7d6080e7          	jalr	2006(ra) # 80003020 <bfree>
    80003852:	b7ed                	j	8000383c <itrunc+0x8a>
    brelse(bp);
    80003854:	8552                	mv	a0,s4
    80003856:	fffff097          	auipc	ra,0xfffff
    8000385a:	6b4080e7          	jalr	1716(ra) # 80002f0a <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT]);
    8000385e:	07c9a583          	lw	a1,124(s3)
    80003862:	0009a503          	lw	a0,0(s3)
    80003866:	fffff097          	auipc	ra,0xfffff
    8000386a:	7ba080e7          	jalr	1978(ra) # 80003020 <bfree>
    ip->addrs[NDIRECT] = 0;
    8000386e:	0609ae23          	sw	zero,124(s3)
    80003872:	b759                	j	800037f8 <itrunc+0x46>
    bp = bread(ip->dev, ip->addrs[NDIRECT + 1]);
    80003874:	0009a503          	lw	a0,0(s3)
    80003878:	fffff097          	auipc	ra,0xfffff
    8000387c:	562080e7          	jalr	1378(ra) # 80002dda <bread>
    80003880:	8c2a                	mv	s8,a0
    for(j = 0; j < NINDIRECT; j++){
    80003882:	05850a13          	addi	s4,a0,88
    80003886:	45850b13          	addi	s6,a0,1112
    8000388a:	a82d                	j	800038c4 <itrunc+0x112>
        for(k = 0; k < NINDIRECT; k++){
    8000388c:	0491                	addi	s1,s1,4
    8000388e:	00990b63          	beq	s2,s1,800038a4 <itrunc+0xf2>
          if(a2[k])
    80003892:	408c                	lw	a1,0(s1)
    80003894:	dde5                	beqz	a1,8000388c <itrunc+0xda>
            bfree(ip->dev, a2[k]);
    80003896:	0009a503          	lw	a0,0(s3)
    8000389a:	fffff097          	auipc	ra,0xfffff
    8000389e:	786080e7          	jalr	1926(ra) # 80003020 <bfree>
    800038a2:	b7ed                	j	8000388c <itrunc+0xda>
        brelse(bp2);
    800038a4:	855e                	mv	a0,s7
    800038a6:	fffff097          	auipc	ra,0xfffff
    800038aa:	664080e7          	jalr	1636(ra) # 80002f0a <brelse>
        bfree(ip->dev, a[j]);
    800038ae:	000aa583          	lw	a1,0(s5)
    800038b2:	0009a503          	lw	a0,0(s3)
    800038b6:	fffff097          	auipc	ra,0xfffff
    800038ba:	76a080e7          	jalr	1898(ra) # 80003020 <bfree>
    for(j = 0; j < NINDIRECT; j++){
    800038be:	0a11                	addi	s4,s4,4
    800038c0:	034b0263          	beq	s6,s4,800038e4 <itrunc+0x132>
      if(a[j]){
    800038c4:	8ad2                	mv	s5,s4
    800038c6:	000a2583          	lw	a1,0(s4)
    800038ca:	d9f5                	beqz	a1,800038be <itrunc+0x10c>
        struct buf *bp2 = bread(ip->dev, a[j]);
    800038cc:	0009a503          	lw	a0,0(s3)
    800038d0:	fffff097          	auipc	ra,0xfffff
    800038d4:	50a080e7          	jalr	1290(ra) # 80002dda <bread>
    800038d8:	8baa                	mv	s7,a0
        for(k = 0; k < NINDIRECT; k++){
    800038da:	05850493          	addi	s1,a0,88
    800038de:	45850913          	addi	s2,a0,1112
    800038e2:	bf45                	j	80003892 <itrunc+0xe0>
    brelse(bp);
    800038e4:	8562                	mv	a0,s8
    800038e6:	fffff097          	auipc	ra,0xfffff
    800038ea:	624080e7          	jalr	1572(ra) # 80002f0a <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT + 1]);
    800038ee:	0809a583          	lw	a1,128(s3)
    800038f2:	0009a503          	lw	a0,0(s3)
    800038f6:	fffff097          	auipc	ra,0xfffff
    800038fa:	72a080e7          	jalr	1834(ra) # 80003020 <bfree>
    ip->addrs[NDIRECT + 1] = 0;
    800038fe:	0809a023          	sw	zero,128(s3)
    80003902:	bdf5                	j	800037fe <itrunc+0x4c>

0000000080003904 <iput>:
{
    80003904:	1101                	addi	sp,sp,-32
    80003906:	ec06                	sd	ra,24(sp)
    80003908:	e822                	sd	s0,16(sp)
    8000390a:	e426                	sd	s1,8(sp)
    8000390c:	e04a                	sd	s2,0(sp)
    8000390e:	1000                	addi	s0,sp,32
    80003910:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    80003912:	00017517          	auipc	a0,0x17
    80003916:	2ae50513          	addi	a0,a0,686 # 8001abc0 <icache>
    8000391a:	ffffd097          	auipc	ra,0xffffd
    8000391e:	2a8080e7          	jalr	680(ra) # 80000bc2 <acquire>
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    80003922:	4498                	lw	a4,8(s1)
    80003924:	4785                	li	a5,1
    80003926:	02f70363          	beq	a4,a5,8000394c <iput+0x48>
  ip->ref--;
    8000392a:	449c                	lw	a5,8(s1)
    8000392c:	37fd                	addiw	a5,a5,-1
    8000392e:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    80003930:	00017517          	auipc	a0,0x17
    80003934:	29050513          	addi	a0,a0,656 # 8001abc0 <icache>
    80003938:	ffffd097          	auipc	ra,0xffffd
    8000393c:	33e080e7          	jalr	830(ra) # 80000c76 <release>
}
    80003940:	60e2                	ld	ra,24(sp)
    80003942:	6442                	ld	s0,16(sp)
    80003944:	64a2                	ld	s1,8(sp)
    80003946:	6902                	ld	s2,0(sp)
    80003948:	6105                	addi	sp,sp,32
    8000394a:	8082                	ret
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    8000394c:	40bc                	lw	a5,64(s1)
    8000394e:	dff1                	beqz	a5,8000392a <iput+0x26>
    80003950:	04a49783          	lh	a5,74(s1)
    80003954:	fbf9                	bnez	a5,8000392a <iput+0x26>
    acquiresleep(&ip->lock);
    80003956:	01048913          	addi	s2,s1,16
    8000395a:	854a                	mv	a0,s2
    8000395c:	00001097          	auipc	ra,0x1
    80003960:	238080e7          	jalr	568(ra) # 80004b94 <acquiresleep>
    release(&icache.lock);
    80003964:	00017517          	auipc	a0,0x17
    80003968:	25c50513          	addi	a0,a0,604 # 8001abc0 <icache>
    8000396c:	ffffd097          	auipc	ra,0xffffd
    80003970:	30a080e7          	jalr	778(ra) # 80000c76 <release>
    itrunc(ip);
    80003974:	8526                	mv	a0,s1
    80003976:	00000097          	auipc	ra,0x0
    8000397a:	e3c080e7          	jalr	-452(ra) # 800037b2 <itrunc>
    ip->type = 0;
    8000397e:	04049223          	sh	zero,68(s1)
    iupdate(ip);
    80003982:	8526                	mv	a0,s1
    80003984:	00000097          	auipc	ra,0x0
    80003988:	c54080e7          	jalr	-940(ra) # 800035d8 <iupdate>
    ip->valid = 0;
    8000398c:	0404a023          	sw	zero,64(s1)
    releasesleep(&ip->lock);
    80003990:	854a                	mv	a0,s2
    80003992:	00001097          	auipc	ra,0x1
    80003996:	258080e7          	jalr	600(ra) # 80004bea <releasesleep>
    acquire(&icache.lock);
    8000399a:	00017517          	auipc	a0,0x17
    8000399e:	22650513          	addi	a0,a0,550 # 8001abc0 <icache>
    800039a2:	ffffd097          	auipc	ra,0xffffd
    800039a6:	220080e7          	jalr	544(ra) # 80000bc2 <acquire>
    800039aa:	b741                	j	8000392a <iput+0x26>

00000000800039ac <iunlockput>:
{
    800039ac:	1101                	addi	sp,sp,-32
    800039ae:	ec06                	sd	ra,24(sp)
    800039b0:	e822                	sd	s0,16(sp)
    800039b2:	e426                	sd	s1,8(sp)
    800039b4:	1000                	addi	s0,sp,32
    800039b6:	84aa                	mv	s1,a0
  iunlock(ip);
    800039b8:	00000097          	auipc	ra,0x0
    800039bc:	dae080e7          	jalr	-594(ra) # 80003766 <iunlock>
  iput(ip);
    800039c0:	8526                	mv	a0,s1
    800039c2:	00000097          	auipc	ra,0x0
    800039c6:	f42080e7          	jalr	-190(ra) # 80003904 <iput>
}
    800039ca:	60e2                	ld	ra,24(sp)
    800039cc:	6442                	ld	s0,16(sp)
    800039ce:	64a2                	ld	s1,8(sp)
    800039d0:	6105                	addi	sp,sp,32
    800039d2:	8082                	ret

00000000800039d4 <stati>:

// Copy stat information from inode.
// Caller must hold ip->lock.
void
stati(struct inode *ip, struct stat *st)
{
    800039d4:	1141                	addi	sp,sp,-16
    800039d6:	e422                	sd	s0,8(sp)
    800039d8:	0800                	addi	s0,sp,16
  st->dev = ip->dev;
    800039da:	411c                	lw	a5,0(a0)
    800039dc:	c19c                	sw	a5,0(a1)
  st->ino = ip->inum;
    800039de:	415c                	lw	a5,4(a0)
    800039e0:	c1dc                	sw	a5,4(a1)
  st->type = ip->type;
    800039e2:	04451783          	lh	a5,68(a0)
    800039e6:	00f59423          	sh	a5,8(a1)
  st->nlink = ip->nlink;
    800039ea:	04a51783          	lh	a5,74(a0)
    800039ee:	00f59523          	sh	a5,10(a1)
  st->size = ip->size;
    800039f2:	04c56783          	lwu	a5,76(a0)
    800039f6:	e99c                	sd	a5,16(a1)
}
    800039f8:	6422                	ld	s0,8(sp)
    800039fa:	0141                	addi	sp,sp,16
    800039fc:	8082                	ret

00000000800039fe <readi>:
readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    800039fe:	457c                	lw	a5,76(a0)
    80003a00:	0ed7e963          	bltu	a5,a3,80003af2 <readi+0xf4>
{
    80003a04:	7159                	addi	sp,sp,-112
    80003a06:	f486                	sd	ra,104(sp)
    80003a08:	f0a2                	sd	s0,96(sp)
    80003a0a:	eca6                	sd	s1,88(sp)
    80003a0c:	e8ca                	sd	s2,80(sp)
    80003a0e:	e4ce                	sd	s3,72(sp)
    80003a10:	e0d2                	sd	s4,64(sp)
    80003a12:	fc56                	sd	s5,56(sp)
    80003a14:	f85a                	sd	s6,48(sp)
    80003a16:	f45e                	sd	s7,40(sp)
    80003a18:	f062                	sd	s8,32(sp)
    80003a1a:	ec66                	sd	s9,24(sp)
    80003a1c:	e86a                	sd	s10,16(sp)
    80003a1e:	e46e                	sd	s11,8(sp)
    80003a20:	1880                	addi	s0,sp,112
    80003a22:	8baa                	mv	s7,a0
    80003a24:	8c2e                	mv	s8,a1
    80003a26:	8ab2                	mv	s5,a2
    80003a28:	84b6                	mv	s1,a3
    80003a2a:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003a2c:	9f35                	addw	a4,a4,a3
    return 0;
    80003a2e:	4501                	li	a0,0
  if(off > ip->size || off + n < off)
    80003a30:	0ad76063          	bltu	a4,a3,80003ad0 <readi+0xd2>
  if(off + n > ip->size)
    80003a34:	00e7f463          	bgeu	a5,a4,80003a3c <readi+0x3e>
    n = ip->size - off;
    80003a38:	40d78b3b          	subw	s6,a5,a3

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003a3c:	0a0b0963          	beqz	s6,80003aee <readi+0xf0>
    80003a40:	4981                	li	s3,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003a42:	40000d13          	li	s10,1024
    if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) {
    80003a46:	5cfd                	li	s9,-1
    80003a48:	a82d                	j	80003a82 <readi+0x84>
    80003a4a:	020a1d93          	slli	s11,s4,0x20
    80003a4e:	020ddd93          	srli	s11,s11,0x20
    80003a52:	05890613          	addi	a2,s2,88
    80003a56:	86ee                	mv	a3,s11
    80003a58:	963a                	add	a2,a2,a4
    80003a5a:	85d6                	mv	a1,s5
    80003a5c:	8562                	mv	a0,s8
    80003a5e:	fffff097          	auipc	ra,0xfffff
    80003a62:	9be080e7          	jalr	-1602(ra) # 8000241c <either_copyout>
    80003a66:	05950d63          	beq	a0,s9,80003ac0 <readi+0xc2>
      brelse(bp);
      tot = -1;
      break;
    }
    brelse(bp);
    80003a6a:	854a                	mv	a0,s2
    80003a6c:	fffff097          	auipc	ra,0xfffff
    80003a70:	49e080e7          	jalr	1182(ra) # 80002f0a <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003a74:	013a09bb          	addw	s3,s4,s3
    80003a78:	009a04bb          	addw	s1,s4,s1
    80003a7c:	9aee                	add	s5,s5,s11
    80003a7e:	0569f763          	bgeu	s3,s6,80003acc <readi+0xce>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003a82:	000ba903          	lw	s2,0(s7)
    80003a86:	00a4d59b          	srliw	a1,s1,0xa
    80003a8a:	855e                	mv	a0,s7
    80003a8c:	fffff097          	auipc	ra,0xfffff
    80003a90:	73e080e7          	jalr	1854(ra) # 800031ca <bmap>
    80003a94:	0005059b          	sext.w	a1,a0
    80003a98:	854a                	mv	a0,s2
    80003a9a:	fffff097          	auipc	ra,0xfffff
    80003a9e:	340080e7          	jalr	832(ra) # 80002dda <bread>
    80003aa2:	892a                	mv	s2,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003aa4:	3ff4f713          	andi	a4,s1,1023
    80003aa8:	40ed07bb          	subw	a5,s10,a4
    80003aac:	413b06bb          	subw	a3,s6,s3
    80003ab0:	8a3e                	mv	s4,a5
    80003ab2:	2781                	sext.w	a5,a5
    80003ab4:	0006861b          	sext.w	a2,a3
    80003ab8:	f8f679e3          	bgeu	a2,a5,80003a4a <readi+0x4c>
    80003abc:	8a36                	mv	s4,a3
    80003abe:	b771                	j	80003a4a <readi+0x4c>
      brelse(bp);
    80003ac0:	854a                	mv	a0,s2
    80003ac2:	fffff097          	auipc	ra,0xfffff
    80003ac6:	448080e7          	jalr	1096(ra) # 80002f0a <brelse>
      tot = -1;
    80003aca:	59fd                	li	s3,-1
  }
  return tot;
    80003acc:	0009851b          	sext.w	a0,s3
}
    80003ad0:	70a6                	ld	ra,104(sp)
    80003ad2:	7406                	ld	s0,96(sp)
    80003ad4:	64e6                	ld	s1,88(sp)
    80003ad6:	6946                	ld	s2,80(sp)
    80003ad8:	69a6                	ld	s3,72(sp)
    80003ada:	6a06                	ld	s4,64(sp)
    80003adc:	7ae2                	ld	s5,56(sp)
    80003ade:	7b42                	ld	s6,48(sp)
    80003ae0:	7ba2                	ld	s7,40(sp)
    80003ae2:	7c02                	ld	s8,32(sp)
    80003ae4:	6ce2                	ld	s9,24(sp)
    80003ae6:	6d42                	ld	s10,16(sp)
    80003ae8:	6da2                	ld	s11,8(sp)
    80003aea:	6165                	addi	sp,sp,112
    80003aec:	8082                	ret
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003aee:	89da                	mv	s3,s6
    80003af0:	bff1                	j	80003acc <readi+0xce>
    return 0;
    80003af2:	4501                	li	a0,0
}
    80003af4:	8082                	ret

0000000080003af6 <writei>:
writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003af6:	457c                	lw	a5,76(a0)
    80003af8:	10d7e963          	bltu	a5,a3,80003c0a <writei+0x114>
{
    80003afc:	7159                	addi	sp,sp,-112
    80003afe:	f486                	sd	ra,104(sp)
    80003b00:	f0a2                	sd	s0,96(sp)
    80003b02:	eca6                	sd	s1,88(sp)
    80003b04:	e8ca                	sd	s2,80(sp)
    80003b06:	e4ce                	sd	s3,72(sp)
    80003b08:	e0d2                	sd	s4,64(sp)
    80003b0a:	fc56                	sd	s5,56(sp)
    80003b0c:	f85a                	sd	s6,48(sp)
    80003b0e:	f45e                	sd	s7,40(sp)
    80003b10:	f062                	sd	s8,32(sp)
    80003b12:	ec66                	sd	s9,24(sp)
    80003b14:	e86a                	sd	s10,16(sp)
    80003b16:	e46e                	sd	s11,8(sp)
    80003b18:	1880                	addi	s0,sp,112
    80003b1a:	8b2a                	mv	s6,a0
    80003b1c:	8c2e                	mv	s8,a1
    80003b1e:	8ab2                	mv	s5,a2
    80003b20:	8936                	mv	s2,a3
    80003b22:	8bba                	mv	s7,a4
  if(off > ip->size || off + n < off)
    80003b24:	9f35                	addw	a4,a4,a3
    80003b26:	0ed76463          	bltu	a4,a3,80003c0e <writei+0x118>
    return -1;
  if(off + n > MAXFILE*BSIZE)
    80003b2a:	040437b7          	lui	a5,0x4043
    80003b2e:	c0078793          	addi	a5,a5,-1024 # 4042c00 <_entry-0x7bfbd400>
    80003b32:	0ee7e063          	bltu	a5,a4,80003c12 <writei+0x11c>
    return -1;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003b36:	0c0b8863          	beqz	s7,80003c06 <writei+0x110>
    80003b3a:	4a01                	li	s4,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003b3c:	40000d13          	li	s10,1024
    if(either_copyin(bp->data + (off % BSIZE), user_src, src, m) == -1) {
    80003b40:	5cfd                	li	s9,-1
    80003b42:	a091                	j	80003b86 <writei+0x90>
    80003b44:	02099d93          	slli	s11,s3,0x20
    80003b48:	020ddd93          	srli	s11,s11,0x20
    80003b4c:	05848513          	addi	a0,s1,88
    80003b50:	86ee                	mv	a3,s11
    80003b52:	8656                	mv	a2,s5
    80003b54:	85e2                	mv	a1,s8
    80003b56:	953a                	add	a0,a0,a4
    80003b58:	fffff097          	auipc	ra,0xfffff
    80003b5c:	91a080e7          	jalr	-1766(ra) # 80002472 <either_copyin>
    80003b60:	07950263          	beq	a0,s9,80003bc4 <writei+0xce>
      brelse(bp);
      break;
    }
    log_write(bp);
    80003b64:	8526                	mv	a0,s1
    80003b66:	00001097          	auipc	ra,0x1
    80003b6a:	f08080e7          	jalr	-248(ra) # 80004a6e <log_write>
    brelse(bp);
    80003b6e:	8526                	mv	a0,s1
    80003b70:	fffff097          	auipc	ra,0xfffff
    80003b74:	39a080e7          	jalr	922(ra) # 80002f0a <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003b78:	01498a3b          	addw	s4,s3,s4
    80003b7c:	0129893b          	addw	s2,s3,s2
    80003b80:	9aee                	add	s5,s5,s11
    80003b82:	057a7663          	bgeu	s4,s7,80003bce <writei+0xd8>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003b86:	000b2483          	lw	s1,0(s6)
    80003b8a:	00a9559b          	srliw	a1,s2,0xa
    80003b8e:	855a                	mv	a0,s6
    80003b90:	fffff097          	auipc	ra,0xfffff
    80003b94:	63a080e7          	jalr	1594(ra) # 800031ca <bmap>
    80003b98:	0005059b          	sext.w	a1,a0
    80003b9c:	8526                	mv	a0,s1
    80003b9e:	fffff097          	auipc	ra,0xfffff
    80003ba2:	23c080e7          	jalr	572(ra) # 80002dda <bread>
    80003ba6:	84aa                	mv	s1,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003ba8:	3ff97713          	andi	a4,s2,1023
    80003bac:	40ed07bb          	subw	a5,s10,a4
    80003bb0:	414b86bb          	subw	a3,s7,s4
    80003bb4:	89be                	mv	s3,a5
    80003bb6:	2781                	sext.w	a5,a5
    80003bb8:	0006861b          	sext.w	a2,a3
    80003bbc:	f8f674e3          	bgeu	a2,a5,80003b44 <writei+0x4e>
    80003bc0:	89b6                	mv	s3,a3
    80003bc2:	b749                	j	80003b44 <writei+0x4e>
      brelse(bp);
    80003bc4:	8526                	mv	a0,s1
    80003bc6:	fffff097          	auipc	ra,0xfffff
    80003bca:	344080e7          	jalr	836(ra) # 80002f0a <brelse>
  }

  if(off > ip->size)
    80003bce:	04cb2783          	lw	a5,76(s6)
    80003bd2:	0127f463          	bgeu	a5,s2,80003bda <writei+0xe4>
    ip->size = off;
    80003bd6:	052b2623          	sw	s2,76(s6)

  // write the i-node back to disk even if the size didn't change
  // because the loop above might have called bmap() and added a new
  // block to ip->addrs[].
  iupdate(ip);
    80003bda:	855a                	mv	a0,s6
    80003bdc:	00000097          	auipc	ra,0x0
    80003be0:	9fc080e7          	jalr	-1540(ra) # 800035d8 <iupdate>

  return tot;
    80003be4:	000a051b          	sext.w	a0,s4
}
    80003be8:	70a6                	ld	ra,104(sp)
    80003bea:	7406                	ld	s0,96(sp)
    80003bec:	64e6                	ld	s1,88(sp)
    80003bee:	6946                	ld	s2,80(sp)
    80003bf0:	69a6                	ld	s3,72(sp)
    80003bf2:	6a06                	ld	s4,64(sp)
    80003bf4:	7ae2                	ld	s5,56(sp)
    80003bf6:	7b42                	ld	s6,48(sp)
    80003bf8:	7ba2                	ld	s7,40(sp)
    80003bfa:	7c02                	ld	s8,32(sp)
    80003bfc:	6ce2                	ld	s9,24(sp)
    80003bfe:	6d42                	ld	s10,16(sp)
    80003c00:	6da2                	ld	s11,8(sp)
    80003c02:	6165                	addi	sp,sp,112
    80003c04:	8082                	ret
  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003c06:	8a5e                	mv	s4,s7
    80003c08:	bfc9                	j	80003bda <writei+0xe4>
    return -1;
    80003c0a:	557d                	li	a0,-1
}
    80003c0c:	8082                	ret
    return -1;
    80003c0e:	557d                	li	a0,-1
    80003c10:	bfe1                	j	80003be8 <writei+0xf2>
    return -1;
    80003c12:	557d                	li	a0,-1
    80003c14:	bfd1                	j	80003be8 <writei+0xf2>

0000000080003c16 <namecmp>:

// Directories

int
namecmp(const char *s, const char *t)
{
    80003c16:	1141                	addi	sp,sp,-16
    80003c18:	e406                	sd	ra,8(sp)
    80003c1a:	e022                	sd	s0,0(sp)
    80003c1c:	0800                	addi	s0,sp,16
  return strncmp(s, t, DIRSIZ);
    80003c1e:	4639                	li	a2,14
    80003c20:	ffffd097          	auipc	ra,0xffffd
    80003c24:	176080e7          	jalr	374(ra) # 80000d96 <strncmp>
}
    80003c28:	60a2                	ld	ra,8(sp)
    80003c2a:	6402                	ld	s0,0(sp)
    80003c2c:	0141                	addi	sp,sp,16
    80003c2e:	8082                	ret

0000000080003c30 <rbtn>:

// 系统查找ip->dev所在的设备上的块号为block的块中存储的结构体
int
rbtn(struct inode *ip, int user_dst, uint64 dst, int n, int block)
{
    80003c30:	7179                	addi	sp,sp,-48
    80003c32:	f406                	sd	ra,40(sp)
    80003c34:	f022                	sd	s0,32(sp)
    80003c36:	ec26                	sd	s1,24(sp)
    80003c38:	e84a                	sd	s2,16(sp)
    80003c3a:	e44e                	sd	s3,8(sp)
    80003c3c:	1800                	addi	s0,sp,48
    80003c3e:	84ae                	mv	s1,a1
    80003c40:	89b2                	mv	s3,a2
  struct buf *bp;
  bp = bread(ip->dev, block);
    80003c42:	85ba                	mv	a1,a4
    80003c44:	4108                	lw	a0,0(a0)
    80003c46:	fffff097          	auipc	ra,0xfffff
    80003c4a:	194080e7          	jalr	404(ra) # 80002dda <bread>
    80003c4e:	892a                	mv	s2,a0
  if(either_copyout(user_dst, dst, bp->data, sizeof(struct btreenode)) == -1) {
    80003c50:	26c00693          	li	a3,620
    80003c54:	05850613          	addi	a2,a0,88
    80003c58:	85ce                	mv	a1,s3
    80003c5a:	8526                	mv	a0,s1
    80003c5c:	ffffe097          	auipc	ra,0xffffe
    80003c60:	7c0080e7          	jalr	1984(ra) # 8000241c <either_copyout>
    80003c64:	57fd                	li	a5,-1
    80003c66:	02f50163          	beq	a0,a5,80003c88 <rbtn+0x58>
    brelse(bp); // 释放缓冲区
    return -1;  // 设置错误标志
  }
  // 释放缓冲区（注意：在成功复制数据后应立即释放，以避免内存泄漏）
  brelse(bp);
    80003c6a:	854a                	mv	a0,s2
    80003c6c:	fffff097          	auipc	ra,0xfffff
    80003c70:	29e080e7          	jalr	670(ra) # 80002f0a <brelse>
  return sizeof(struct btreenode);
    80003c74:	26c00493          	li	s1,620
}
    80003c78:	8526                	mv	a0,s1
    80003c7a:	70a2                	ld	ra,40(sp)
    80003c7c:	7402                	ld	s0,32(sp)
    80003c7e:	64e2                	ld	s1,24(sp)
    80003c80:	6942                	ld	s2,16(sp)
    80003c82:	69a2                	ld	s3,8(sp)
    80003c84:	6145                	addi	sp,sp,48
    80003c86:	8082                	ret
    80003c88:	84aa                	mv	s1,a0
    brelse(bp); // 释放缓冲区
    80003c8a:	854a                	mv	a0,s2
    80003c8c:	fffff097          	auipc	ra,0xfffff
    80003c90:	27e080e7          	jalr	638(ra) # 80002f0a <brelse>
    return -1;  // 设置错误标志
    80003c94:	b7d5                	j	80003c78 <rbtn+0x48>

0000000080003c96 <btnalloc>:

// 申请一个btreenode节点
void
btnalloc(struct btreenode *btn, struct inode *ip) 
{
    80003c96:	1101                	addi	sp,sp,-32
    80003c98:	ec06                	sd	ra,24(sp)
    80003c9a:	e822                	sd	s0,16(sp)
    80003c9c:	e426                	sd	s1,8(sp)
    80003c9e:	1000                	addi	s0,sp,32
    80003ca0:	84aa                	mv	s1,a0
  btn->isleaf = 1;
    80003ca2:	4785                	li	a5,1
    80003ca4:	c11c                	sw	a5,0(a0)
  btn->numkeys = 0;
    80003ca6:	00052223          	sw	zero,4(a0)
  btn->childnum = 0;
    80003caa:	00052423          	sw	zero,8(a0)
  // 分配一个空闲块
  btn->block = balloc(ip->dev);
    80003cae:	4188                	lw	a0,0(a1)
    80003cb0:	fffff097          	auipc	ra,0xfffff
    80003cb4:	3ec080e7          	jalr	1004(ra) # 8000309c <balloc>
    80003cb8:	26a4a423          	sw	a0,616(s1)
  // 将孩子节点的指针都设为 block 0，即无效状态
  for(int i = 0; i < MAXBTN; i++){
    80003cbc:	1ec48793          	addi	a5,s1,492
    80003cc0:	26448713          	addi	a4,s1,612
      btn->children[i] = 0;
    80003cc4:	0007a023          	sw	zero,0(a5)
  for(int i = 0; i < MAXBTN; i++){
    80003cc8:	0791                	addi	a5,a5,4
    80003cca:	fee79de3          	bne	a5,a4,80003cc4 <btnalloc+0x2e>
  }
}
    80003cce:	60e2                	ld	ra,24(sp)
    80003cd0:	6442                	ld	s0,16(sp)
    80003cd2:	64a2                	ld	s1,8(sp)
    80003cd4:	6105                	addi	sp,sp,32
    80003cd6:	8082                	ret

0000000080003cd8 <btnfind>:

// 根据name找到应该插入的B树节点，并存储查找的路径
int
btnfind(struct btreenode *btn, struct inode *ip, struct btreetable *btt, char *name){
    80003cd8:	711d                	addi	sp,sp,-96
    80003cda:	ec86                	sd	ra,88(sp)
    80003cdc:	e8a2                	sd	s0,80(sp)
    80003cde:	e4a6                	sd	s1,72(sp)
    80003ce0:	e0ca                	sd	s2,64(sp)
    80003ce2:	fc4e                	sd	s3,56(sp)
    80003ce4:	f852                	sd	s4,48(sp)
    80003ce6:	f456                	sd	s5,40(sp)
    80003ce8:	f05a                	sd	s6,32(sp)
    80003cea:	ec5e                	sd	s7,24(sp)
    80003cec:	e862                	sd	s8,16(sp)
    80003cee:	e466                	sd	s9,8(sp)
    80003cf0:	1080                	addi	s0,sp,96
    80003cf2:	89aa                	mv	s3,a0
    80003cf4:	8b2e                	mv	s6,a1
    80003cf6:	8ab2                	mv	s5,a2
    80003cf8:	8a36                	mv	s4,a3
  struct buf *bp;
  // B树根节点所在块号
  uint blocknum = ip->addrs[0];
    80003cfa:	0505ac83          	lw	s9,80(a1)
    // 维护路径栈和栈顶指针
    btt->btstack[btt->stacktop++] = blocknum; 
    // 找到叶子节点，成功返回
    if(btn->isleaf) return 0;
    // 不是叶子节点，则继续寻找
    int i = 0;
    80003cfe:	4b81                	li	s7,0
  if(blocknum == 0){
    80003d00:	040c9e63          	bnez	s9,80003d5c <btnfind+0x84>
    btnalloc(btn, ip);
    80003d04:	00000097          	auipc	ra,0x0
    80003d08:	f92080e7          	jalr	-110(ra) # 80003c96 <btnalloc>
    ip->addrs[0] = btn->block;
    80003d0c:	2689a783          	lw	a5,616(s3)
    80003d10:	04fb2823          	sw	a5,80(s6)
    ip->size = sizeof(struct btreenode);
    80003d14:	26c00793          	li	a5,620
    80003d18:	04fb2623          	sw	a5,76(s6)
    btt->btstack[btt->stacktop++] = btn->block;
    80003d1c:	028aa783          	lw	a5,40(s5)
    80003d20:	0017871b          	addiw	a4,a5,1
    80003d24:	02eaa423          	sw	a4,40(s5)
    80003d28:	2689a703          	lw	a4,616(s3)
    80003d2c:	02079693          	slli	a3,a5,0x20
    80003d30:	01e6d793          	srli	a5,a3,0x1e
    80003d34:	9abe                	add	s5,s5,a5
    80003d36:	00eaa023          	sw	a4,0(s5)
    iupdate(ip);
    80003d3a:	855a                	mv	a0,s6
    80003d3c:	00000097          	auipc	ra,0x0
    80003d40:	89c080e7          	jalr	-1892(ra) # 800035d8 <iupdate>
    return 0;
    80003d44:	4501                	li	a0,0
    80003d46:	a845                	j	80003df6 <btnfind+0x11e>
    for(; i < btn->numkeys; i++){
      int res = namecmp(name, btn->keys[i].name);
      if(res == 0){       // name == keys[i].name
        return -1;        // 存在同名目录项，失败返回
      }else if(res < 0){  // name < b.keys[i].name
        blocknum = btn->children[i];
    80003d48:	07890793          	addi	a5,s2,120
    80003d4c:	078a                	slli	a5,a5,0x2
    80003d4e:	97ce                	add	a5,a5,s3
    80003d50:	00c7ac83          	lw	s9,12(a5)
        break;            // 继续寻找对应的子节点
      }
    }
    // 继续寻找对应的子节点
    if(i == btn->numkeys) blocknum = btn->children[i];
    80003d54:	0049a783          	lw	a5,4(s3)
    80003d58:	08978563          	beq	a5,s1,80003de2 <btnfind+0x10a>
    bp = bread(ip->dev, blocknum);
    80003d5c:	85e6                	mv	a1,s9
    80003d5e:	000b2503          	lw	a0,0(s6)
    80003d62:	fffff097          	auipc	ra,0xfffff
    80003d66:	078080e7          	jalr	120(ra) # 80002dda <bread>
    80003d6a:	84aa                	mv	s1,a0
    memmove(btn, bp->data, sizeof(struct btreenode));
    80003d6c:	26c00613          	li	a2,620
    80003d70:	05850593          	addi	a1,a0,88
    80003d74:	854e                	mv	a0,s3
    80003d76:	ffffd097          	auipc	ra,0xffffd
    80003d7a:	fa4080e7          	jalr	-92(ra) # 80000d1a <memmove>
    brelse(bp);
    80003d7e:	8526                	mv	a0,s1
    80003d80:	fffff097          	auipc	ra,0xfffff
    80003d84:	18a080e7          	jalr	394(ra) # 80002f0a <brelse>
    btt->btstack[btt->stacktop++] = blocknum; 
    80003d88:	028aa783          	lw	a5,40(s5)
    80003d8c:	0017871b          	addiw	a4,a5,1
    80003d90:	02eaa423          	sw	a4,40(s5)
    80003d94:	02079713          	slli	a4,a5,0x20
    80003d98:	01e75793          	srli	a5,a4,0x1e
    80003d9c:	97d6                	add	a5,a5,s5
    80003d9e:	0197a023          	sw	s9,0(a5)
    if(btn->isleaf) return 0;
    80003da2:	0009a783          	lw	a5,0(s3)
    80003da6:	e7a9                	bnez	a5,80003df0 <btnfind+0x118>
    for(; i < btn->numkeys; i++){
    80003da8:	0049a783          	lw	a5,4(s3)
    80003dac:	cb95                	beqz	a5,80003de0 <btnfind+0x108>
    80003dae:	00e98c13          	addi	s8,s3,14
    int i = 0;
    80003db2:	895e                	mv	s2,s7
    80003db4:	0009049b          	sext.w	s1,s2
      int res = namecmp(name, btn->keys[i].name);
    80003db8:	85e2                	mv	a1,s8
    80003dba:	8552                	mv	a0,s4
    80003dbc:	00000097          	auipc	ra,0x0
    80003dc0:	e5a080e7          	jalr	-422(ra) # 80003c16 <namecmp>
      if(res == 0){       // name == keys[i].name
    80003dc4:	c905                	beqz	a0,80003df4 <btnfind+0x11c>
      }else if(res < 0){  // name < b.keys[i].name
    80003dc6:	f80541e3          	bltz	a0,80003d48 <btnfind+0x70>
    for(; i < btn->numkeys; i++){
    80003dca:	0019049b          	addiw	s1,s2,1
    80003dce:	0004891b          	sext.w	s2,s1
    80003dd2:	84ca                	mv	s1,s2
    80003dd4:	0c41                	addi	s8,s8,16
    80003dd6:	0049a783          	lw	a5,4(s3)
    80003dda:	fcf96de3          	bltu	s2,a5,80003db4 <btnfind+0xdc>
    80003dde:	bf9d                	j	80003d54 <btnfind+0x7c>
    int i = 0;
    80003de0:	895e                	mv	s2,s7
    if(i == btn->numkeys) blocknum = btn->children[i];
    80003de2:	07890793          	addi	a5,s2,120
    80003de6:	078a                	slli	a5,a5,0x2
    80003de8:	97ce                	add	a5,a5,s3
    80003dea:	00c7ac83          	lw	s9,12(a5)
    80003dee:	b7bd                	j	80003d5c <btnfind+0x84>
    if(btn->isleaf) return 0;
    80003df0:	4501                	li	a0,0
    80003df2:	a011                	j	80003df6 <btnfind+0x11e>
        return -1;        // 存在同名目录项，失败返回
    80003df4:	557d                	li	a0,-1
  }
  return -1;
}
    80003df6:	60e6                	ld	ra,88(sp)
    80003df8:	6446                	ld	s0,80(sp)
    80003dfa:	64a6                	ld	s1,72(sp)
    80003dfc:	6906                	ld	s2,64(sp)
    80003dfe:	79e2                	ld	s3,56(sp)
    80003e00:	7a42                	ld	s4,48(sp)
    80003e02:	7aa2                	ld	s5,40(sp)
    80003e04:	7b02                	ld	s6,32(sp)
    80003e06:	6be2                	ld	s7,24(sp)
    80003e08:	6c42                	ld	s8,16(sp)
    80003e0a:	6ca2                	ld	s9,8(sp)
    80003e0c:	6125                	addi	sp,sp,96
    80003e0e:	8082                	ret

0000000080003e10 <findsuiteindex>:

// 查找此目录项在此B树节点的目标存放位置
int
findsuiteindex(struct btreenode *btn, struct dirent *de) 
{
    80003e10:	7179                	addi	sp,sp,-48
    80003e12:	f406                	sd	ra,40(sp)
    80003e14:	f022                	sd	s0,32(sp)
    80003e16:	ec26                	sd	s1,24(sp)
    80003e18:	e84a                	sd	s2,16(sp)
    80003e1a:	e44e                	sd	s3,8(sp)
    80003e1c:	e052                	sd	s4,0(sp)
    80003e1e:	1800                	addi	s0,sp,48
  int index;
  for (index = 0; index < btn->numkeys; index++) {
    80003e20:	415c                	lw	a5,4(a0)
    80003e22:	c3a9                	beqz	a5,80003e64 <findsuiteindex+0x54>
    80003e24:	8a2a                	mv	s4,a0
    80003e26:	00e50493          	addi	s1,a0,14
    80003e2a:	4901                	li	s2,0
    if (namecmp(de->name, btn->keys[index].name) < 0)
    80003e2c:	00258993          	addi	s3,a1,2
    80003e30:	85a6                	mv	a1,s1
    80003e32:	854e                	mv	a0,s3
    80003e34:	00000097          	auipc	ra,0x0
    80003e38:	de2080e7          	jalr	-542(ra) # 80003c16 <namecmp>
    80003e3c:	00054b63          	bltz	a0,80003e52 <findsuiteindex+0x42>
  for (index = 0; index < btn->numkeys; index++) {
    80003e40:	0019079b          	addiw	a5,s2,1
    80003e44:	0007891b          	sext.w	s2,a5
    80003e48:	04c1                	addi	s1,s1,16
    80003e4a:	004a2703          	lw	a4,4(s4)
    80003e4e:	fee961e3          	bltu	s2,a4,80003e30 <findsuiteindex+0x20>
      break;
  }
  return index;
}
    80003e52:	854a                	mv	a0,s2
    80003e54:	70a2                	ld	ra,40(sp)
    80003e56:	7402                	ld	s0,32(sp)
    80003e58:	64e2                	ld	s1,24(sp)
    80003e5a:	6942                	ld	s2,16(sp)
    80003e5c:	69a2                	ld	s3,8(sp)
    80003e5e:	6a02                	ld	s4,0(sp)
    80003e60:	6145                	addi	sp,sp,48
    80003e62:	8082                	ret
  for (index = 0; index < btn->numkeys; index++) {
    80003e64:	4901                	li	s2,0
    80003e66:	b7f5                	j	80003e52 <findsuiteindex+0x42>

0000000080003e68 <btninsert>:

// 将此目录项插入对应的B树叶节点
int
btninsert(struct btreenode *lbtn, struct inode *ip, struct btreetable *btt, struct dirent *de, int index) 
{
    80003e68:	ae010113          	addi	sp,sp,-1312
    80003e6c:	50113c23          	sd	ra,1304(sp)
    80003e70:	50813823          	sd	s0,1296(sp)
    80003e74:	50913423          	sd	s1,1288(sp)
    80003e78:	51213023          	sd	s2,1280(sp)
    80003e7c:	4f313c23          	sd	s3,1272(sp)
    80003e80:	4f413823          	sd	s4,1264(sp)
    80003e84:	4f513423          	sd	s5,1256(sp)
    80003e88:	4f613023          	sd	s6,1248(sp)
    80003e8c:	52010413          	addi	s0,sp,1312
    80003e90:	89aa                	mv	s3,a0
    80003e92:	8a2e                	mv	s4,a1
    80003e94:	8ab2                	mv	s5,a2
	int i = 0;
  struct buf *bp;
  // 腾出需要添加的目录项的位置
  for (i = lbtn->numkeys; i > index; i--) 
    80003e96:	00452303          	lw	t1,4(a0)
    80003e9a:	0003079b          	sext.w	a5,t1
    80003e9e:	04f75063          	bge	a4,a5,80003ede <btninsert+0x76>
    80003ea2:	00479613          	slli	a2,a5,0x4
    80003ea6:	00c507b3          	add	a5,a0,a2
    80003eaa:	ff050893          	addi	a7,a0,-16
    80003eae:	98b2                	add	a7,a7,a2
    80003eb0:	40e3063b          	subw	a2,t1,a4
    80003eb4:	367d                	addiw	a2,a2,-1
    80003eb6:	02061593          	slli	a1,a2,0x20
    80003eba:	01c5d613          	srli	a2,a1,0x1c
    80003ebe:	40c888b3          	sub	a7,a7,a2
    lbtn->keys[i] = lbtn->keys[i-1];
    80003ec2:	ffc7a503          	lw	a0,-4(a5)
    80003ec6:	438c                	lw	a1,0(a5)
    80003ec8:	43d0                	lw	a2,4(a5)
    80003eca:	0087a803          	lw	a6,8(a5)
    80003ece:	c7c8                	sw	a0,12(a5)
    80003ed0:	cb8c                	sw	a1,16(a5)
    80003ed2:	cbd0                	sw	a2,20(a5)
    80003ed4:	0107ac23          	sw	a6,24(a5)
  for (i = lbtn->numkeys; i > index; i--) 
    80003ed8:	17c1                	addi	a5,a5,-16
    80003eda:	ff1794e3          	bne	a5,a7,80003ec2 <btninsert+0x5a>
  lbtn->keys[index] = *de;
    80003ede:	0712                	slli	a4,a4,0x4
    80003ee0:	00e987b3          	add	a5,s3,a4
    80003ee4:	0006de83          	lhu	t4,0(a3)
    80003ee8:	0026de03          	lhu	t3,2(a3)
    80003eec:	0046d883          	lhu	a7,4(a3)
    80003ef0:	0066d803          	lhu	a6,6(a3)
    80003ef4:	0086d503          	lhu	a0,8(a3)
    80003ef8:	00a6d583          	lhu	a1,10(a3)
    80003efc:	00c6d603          	lhu	a2,12(a3)
    80003f00:	00e6d703          	lhu	a4,14(a3)
    80003f04:	01d79623          	sh	t4,12(a5)
    80003f08:	01c79723          	sh	t3,14(a5)
    80003f0c:	01179823          	sh	a7,16(a5)
    80003f10:	01079923          	sh	a6,18(a5)
    80003f14:	00a79a23          	sh	a0,20(a5)
    80003f18:	00b79b23          	sh	a1,22(a5)
    80003f1c:	00c79c23          	sh	a2,24(a5)
    80003f20:	00e79d23          	sh	a4,26(a5)
  lbtn->numkeys++;
    80003f24:	2305                	addiw	t1,t1,1
    80003f26:	0003071b          	sext.w	a4,t1
    80003f2a:	0069a223          	sw	t1,4(s3)
  // 超过最大关键数
  if ( lbtn->numkeys == MAXBTN ) {
    80003f2e:	47f9                	li	a5,30
    80003f30:	06f70863          	beq	a4,a5,80003fa0 <btninsert+0x138>
      log_write(bp);
      brelse(bp);
      btninsert(&parentbtn, ip, btt, &lbtn->keys[mid], index);
    }
  }else{
    bp = bread(ip->dev, lbtn->block);
    80003f34:	2689a583          	lw	a1,616(s3)
    80003f38:	000a2503          	lw	a0,0(s4)
    80003f3c:	fffff097          	auipc	ra,0xfffff
    80003f40:	e9e080e7          	jalr	-354(ra) # 80002dda <bread>
    80003f44:	892a                	mv	s2,a0
    if(either_copyin(bp->data, 0, (uint64)lbtn, sizeof(struct btreenode)) == -1) {
    80003f46:	26c00693          	li	a3,620
    80003f4a:	864e                	mv	a2,s3
    80003f4c:	4581                	li	a1,0
    80003f4e:	05850513          	addi	a0,a0,88
    80003f52:	ffffe097          	auipc	ra,0xffffe
    80003f56:	520080e7          	jalr	1312(ra) # 80002472 <either_copyin>
    80003f5a:	84aa                	mv	s1,a0
    80003f5c:	57fd                	li	a5,-1
    80003f5e:	3cf50a63          	beq	a0,a5,80004332 <btninsert+0x4ca>
      brelse(bp);
      return -1;
    }
    log_write(bp);
    80003f62:	854a                	mv	a0,s2
    80003f64:	00001097          	auipc	ra,0x1
    80003f68:	b0a080e7          	jalr	-1270(ra) # 80004a6e <log_write>
    brelse(bp);
    80003f6c:	854a                	mv	a0,s2
    80003f6e:	fffff097          	auipc	ra,0xfffff
    80003f72:	f9c080e7          	jalr	-100(ra) # 80002f0a <brelse>
  }
  return 0;
    80003f76:	4481                	li	s1,0
}
    80003f78:	8526                	mv	a0,s1
    80003f7a:	51813083          	ld	ra,1304(sp)
    80003f7e:	51013403          	ld	s0,1296(sp)
    80003f82:	50813483          	ld	s1,1288(sp)
    80003f86:	50013903          	ld	s2,1280(sp)
    80003f8a:	4f813983          	ld	s3,1272(sp)
    80003f8e:	4f013a03          	ld	s4,1264(sp)
    80003f92:	4e813a83          	ld	s5,1256(sp)
    80003f96:	4e013b03          	ld	s6,1248(sp)
    80003f9a:	52010113          	addi	sp,sp,1312
    80003f9e:	8082                	ret
    btnalloc(&rbtn, ip);
    80003fa0:	85d2                	mv	a1,s4
    80003fa2:	ae040513          	addi	a0,s0,-1312
    80003fa6:	00000097          	auipc	ra,0x0
    80003faa:	cf0080e7          	jalr	-784(ra) # 80003c96 <btnalloc>
    rbtn.isleaf = lbtn->isleaf;
    80003fae:	0009a783          	lw	a5,0(s3)
    80003fb2:	aef42023          	sw	a5,-1312(s0)
    for (i = mid + 1; i < lbtn->numkeys; i++) {
    80003fb6:	0049a703          	lw	a4,4(s3)
    80003fba:	47bd                	li	a5,15
    80003fbc:	04e7ff63          	bgeu	a5,a4,8000401a <btninsert+0x1b2>
    80003fc0:	aec40913          	addi	s2,s0,-1300
    80003fc4:	0fe98493          	addi	s1,s3,254
    80003fc8:	4b3d                	li	s6,15
      rbtn.keys[i - mid - 1] = lbtn->keys[i];
    80003fca:	ffe4a603          	lw	a2,-2(s1)
    80003fce:	0024a683          	lw	a3,2(s1)
    80003fd2:	0064a703          	lw	a4,6(s1)
    80003fd6:	00a4a783          	lw	a5,10(s1)
    80003fda:	00c92023          	sw	a2,0(s2)
    80003fde:	00d92223          	sw	a3,4(s2)
    80003fe2:	00e92423          	sw	a4,8(s2)
    80003fe6:	00f92623          	sw	a5,12(s2)
      lbtn->keys[i].inum = 0;
    80003fea:	fe049f23          	sh	zero,-2(s1)
      memset(lbtn->keys[i].name, 0, DIRSIZ);
    80003fee:	4639                	li	a2,14
    80003ff0:	4581                	li	a1,0
    80003ff2:	8526                	mv	a0,s1
    80003ff4:	ffffd097          	auipc	ra,0xffffd
    80003ff8:	cca080e7          	jalr	-822(ra) # 80000cbe <memset>
      rbtn.numkeys++;
    80003ffc:	ae442783          	lw	a5,-1308(s0)
    80004000:	2785                	addiw	a5,a5,1
    80004002:	aef42223          	sw	a5,-1308(s0)
    for (i = mid + 1; i < lbtn->numkeys; i++) {
    80004006:	001b079b          	addiw	a5,s6,1
    8000400a:	00078b1b          	sext.w	s6,a5
    8000400e:	0941                	addi	s2,s2,16
    80004010:	04c1                	addi	s1,s1,16
    80004012:	0049a703          	lw	a4,4(s3)
    80004016:	faeb6ae3          	bltu	s6,a4,80003fca <btninsert+0x162>
    for (i = mid + 1; i < lbtn->childnum; i++) {
    8000401a:	0089a603          	lw	a2,8(s3)
    8000401e:	47bd                	li	a5,15
    80004020:	02c7fc63          	bgeu	a5,a2,80004058 <btninsert+0x1f0>
    80004024:	ae842583          	lw	a1,-1304(s0)
    80004028:	0015871b          	addiw	a4,a1,1
    8000402c:	22898793          	addi	a5,s3,552
    80004030:	ccc40693          	addi	a3,s0,-820
    80004034:	35c9                	addiw	a1,a1,-14
    80004036:	9db1                	addw	a1,a1,a2
      rbtn.children[i - mid - 1] = lbtn->children[i];
    80004038:	4390                	lw	a2,0(a5)
    8000403a:	c290                	sw	a2,0(a3)
      lbtn->children[i] = 0;
    8000403c:	0007a023          	sw	zero,0(a5)
    for (i = mid + 1; i < lbtn->childnum; i++) {
    80004040:	0007061b          	sext.w	a2,a4
    80004044:	2705                	addiw	a4,a4,1
    80004046:	0791                	addi	a5,a5,4
    80004048:	0691                	addi	a3,a3,4
    8000404a:	feb717e3          	bne	a4,a1,80004038 <btninsert+0x1d0>
    8000404e:	aec42423          	sw	a2,-1304(s0)
    if(lbtn->childnum > (mid + 1)) lbtn->childnum = mid + 1;
    80004052:	47bd                	li	a5,15
    80004054:	00f9a423          	sw	a5,8(s3)
    lbtn->numkeys = mid;
    80004058:	47b9                	li	a5,14
    8000405a:	00f9a223          	sw	a5,4(s3)
    if (btt->btstack[0] == lbtn->block) {
    8000405e:	000aa703          	lw	a4,0(s5)
    80004062:	2689a783          	lw	a5,616(s3)
    80004066:	14f70e63          	beq	a4,a5,800041c2 <btninsert+0x35a>
      bp = bread(ip->dev, btt->btstack[--btt->stacktop]);
    8000406a:	000a2503          	lw	a0,0(s4)
    8000406e:	028aa783          	lw	a5,40(s5)
    80004072:	37fd                	addiw	a5,a5,-1
    80004074:	02faa423          	sw	a5,40(s5)
    80004078:	02079713          	slli	a4,a5,0x20
    8000407c:	01e75793          	srli	a5,a4,0x1e
    80004080:	97d6                	add	a5,a5,s5
    80004082:	438c                	lw	a1,0(a5)
    80004084:	fffff097          	auipc	ra,0xfffff
    80004088:	d56080e7          	jalr	-682(ra) # 80002dda <bread>
    8000408c:	84aa                	mv	s1,a0
      memmove(&parentbtn, bp->data, sizeof(struct btreenode));
    8000408e:	26c00613          	li	a2,620
    80004092:	05850593          	addi	a1,a0,88
    80004096:	d5040513          	addi	a0,s0,-688
    8000409a:	ffffd097          	auipc	ra,0xffffd
    8000409e:	c80080e7          	jalr	-896(ra) # 80000d1a <memmove>
      brelse(bp);
    800040a2:	8526                	mv	a0,s1
    800040a4:	fffff097          	auipc	ra,0xfffff
    800040a8:	e66080e7          	jalr	-410(ra) # 80002f0a <brelse>
      index = findsuiteindex(&parentbtn, &lbtn->keys[mid]);
    800040ac:	0ec98913          	addi	s2,s3,236
    800040b0:	85ca                	mv	a1,s2
    800040b2:	d5040513          	addi	a0,s0,-688
    800040b6:	00000097          	auipc	ra,0x0
    800040ba:	d5a080e7          	jalr	-678(ra) # 80003e10 <findsuiteindex>
    800040be:	84aa                	mv	s1,a0
      if (parentbtn.children[index + 1] != 0) {
    800040c0:	0015069b          	addiw	a3,a0,1
    800040c4:	07868793          	addi	a5,a3,120
    800040c8:	078a                	slli	a5,a5,0x2
    800040ca:	fc078793          	addi	a5,a5,-64
    800040ce:	97a2                	add	a5,a5,s0
    800040d0:	d9c7a783          	lw	a5,-612(a5)
    800040d4:	cf8d                	beqz	a5,8000410e <btninsert+0x2a6>
        for (i = parentbtn.numkeys; i > index; i--) {
    800040d6:	d5442603          	lw	a2,-684(s0)
    800040da:	0006071b          	sext.w	a4,a2
    800040de:	02e55863          	bge	a0,a4,8000410e <btninsert+0x2a6>
    800040e2:	07b70793          	addi	a5,a4,123
    800040e6:	078a                	slli	a5,a5,0x2
    800040e8:	d5040593          	addi	a1,s0,-688
    800040ec:	97ae                	add	a5,a5,a1
    800040ee:	070a                	slli	a4,a4,0x2
    800040f0:	f3840593          	addi	a1,s0,-200
    800040f4:	972e                	add	a4,a4,a1
    800040f6:	367d                	addiw	a2,a2,-1
    800040f8:	9e09                	subw	a2,a2,a0
    800040fa:	02061593          	slli	a1,a2,0x20
    800040fe:	01e5d613          	srli	a2,a1,0x1e
    80004102:	8f11                	sub	a4,a4,a2
          parentbtn.children[i + 1] = parentbtn.children[i];
    80004104:	4390                	lw	a2,0(a5)
    80004106:	c3d0                	sw	a2,4(a5)
        for (i = parentbtn.numkeys; i > index; i--) {
    80004108:	17f1                	addi	a5,a5,-4
    8000410a:	fee79de3          	bne	a5,a4,80004104 <btninsert+0x29c>
      parentbtn.children[index + 1] = rbtn.block;
    8000410e:	d4842583          	lw	a1,-696(s0)
    80004112:	07868793          	addi	a5,a3,120
    80004116:	078a                	slli	a5,a5,0x2
    80004118:	fc078793          	addi	a5,a5,-64
    8000411c:	97a2                	add	a5,a5,s0
    8000411e:	d8b7ae23          	sw	a1,-612(a5)
      parentbtn.childnum++;
    80004122:	d5842783          	lw	a5,-680(s0)
    80004126:	2785                	addiw	a5,a5,1
    80004128:	d4f42c23          	sw	a5,-680(s0)
      bp = bread(ip->dev, rbtn.block);
    8000412c:	000a2503          	lw	a0,0(s4)
    80004130:	fffff097          	auipc	ra,0xfffff
    80004134:	caa080e7          	jalr	-854(ra) # 80002dda <bread>
    80004138:	8b2a                	mv	s6,a0
      if(either_copyin(bp->data, 0, (uint64)&rbtn, sizeof(struct btreenode)) == -1) {
    8000413a:	26c00693          	li	a3,620
    8000413e:	ae040613          	addi	a2,s0,-1312
    80004142:	4581                	li	a1,0
    80004144:	05850513          	addi	a0,a0,88
    80004148:	ffffe097          	auipc	ra,0xffffe
    8000414c:	32a080e7          	jalr	810(ra) # 80002472 <either_copyin>
    80004150:	57fd                	li	a5,-1
    80004152:	1cf50363          	beq	a0,a5,80004318 <btninsert+0x4b0>
      log_write(bp);
    80004156:	855a                	mv	a0,s6
    80004158:	00001097          	auipc	ra,0x1
    8000415c:	916080e7          	jalr	-1770(ra) # 80004a6e <log_write>
      brelse(bp);
    80004160:	855a                	mv	a0,s6
    80004162:	fffff097          	auipc	ra,0xfffff
    80004166:	da8080e7          	jalr	-600(ra) # 80002f0a <brelse>
      bp = bread(ip->dev, lbtn->block);
    8000416a:	2689a583          	lw	a1,616(s3)
    8000416e:	000a2503          	lw	a0,0(s4)
    80004172:	fffff097          	auipc	ra,0xfffff
    80004176:	c68080e7          	jalr	-920(ra) # 80002dda <bread>
    8000417a:	8b2a                	mv	s6,a0
      if(either_copyin(bp->data, 0, (uint64)lbtn, sizeof(struct btreenode)) == -1) {
    8000417c:	26c00693          	li	a3,620
    80004180:	864e                	mv	a2,s3
    80004182:	4581                	li	a1,0
    80004184:	05850513          	addi	a0,a0,88
    80004188:	ffffe097          	auipc	ra,0xffffe
    8000418c:	2ea080e7          	jalr	746(ra) # 80002472 <either_copyin>
    80004190:	57fd                	li	a5,-1
    80004192:	18f50a63          	beq	a0,a5,80004326 <btninsert+0x4be>
      log_write(bp);
    80004196:	855a                	mv	a0,s6
    80004198:	00001097          	auipc	ra,0x1
    8000419c:	8d6080e7          	jalr	-1834(ra) # 80004a6e <log_write>
      brelse(bp);
    800041a0:	855a                	mv	a0,s6
    800041a2:	fffff097          	auipc	ra,0xfffff
    800041a6:	d68080e7          	jalr	-664(ra) # 80002f0a <brelse>
      btninsert(&parentbtn, ip, btt, &lbtn->keys[mid], index);
    800041aa:	8726                	mv	a4,s1
    800041ac:	86ca                	mv	a3,s2
    800041ae:	8656                	mv	a2,s5
    800041b0:	85d2                	mv	a1,s4
    800041b2:	d5040513          	addi	a0,s0,-688
    800041b6:	00000097          	auipc	ra,0x0
    800041ba:	cb2080e7          	jalr	-846(ra) # 80003e68 <btninsert>
  return 0;
    800041be:	4481                	li	s1,0
    800041c0:	bb65                	j	80003f78 <btninsert+0x110>
      btnalloc(&newbtn, ip);
    800041c2:	85d2                	mv	a1,s4
    800041c4:	d5040513          	addi	a0,s0,-688
    800041c8:	00000097          	auipc	ra,0x0
    800041cc:	ace080e7          	jalr	-1330(ra) # 80003c96 <btnalloc>
      newbtn.isleaf = 0;
    800041d0:	d4042823          	sw	zero,-688(s0)
      newbtn.keys[0] = lbtn->keys[mid];
    800041d4:	0ec9a603          	lw	a2,236(s3)
    800041d8:	0f09a683          	lw	a3,240(s3)
    800041dc:	0f49a703          	lw	a4,244(s3)
    800041e0:	0f89a783          	lw	a5,248(s3)
    800041e4:	d4c42e23          	sw	a2,-676(s0)
    800041e8:	d6d42023          	sw	a3,-672(s0)
    800041ec:	d6e42223          	sw	a4,-668(s0)
    800041f0:	d6f42423          	sw	a5,-664(s0)
      newbtn.numkeys++;
    800041f4:	d5442783          	lw	a5,-684(s0)
    800041f8:	2785                	addiw	a5,a5,1
    800041fa:	d4f42a23          	sw	a5,-684(s0)
      newbtn.children[0] = lbtn->block;
    800041fe:	2689a783          	lw	a5,616(s3)
    80004202:	f2f42e23          	sw	a5,-196(s0)
      newbtn.children[1] = rbtn.block;
    80004206:	d4842783          	lw	a5,-696(s0)
    8000420a:	f4f42023          	sw	a5,-192(s0)
      newbtn.childnum = 2;
    8000420e:	4789                	li	a5,2
    80004210:	d4f42c23          	sw	a5,-680(s0)
      ip->addrs[0] = newbtn.block;
    80004214:	fb842783          	lw	a5,-72(s0)
    80004218:	04fa2823          	sw	a5,80(s4)
      iupdate(ip);
    8000421c:	8552                	mv	a0,s4
    8000421e:	fffff097          	auipc	ra,0xfffff
    80004222:	3ba080e7          	jalr	954(ra) # 800035d8 <iupdate>
      bp = bread(ip->dev, newbtn.block);
    80004226:	fb842583          	lw	a1,-72(s0)
    8000422a:	000a2503          	lw	a0,0(s4)
    8000422e:	fffff097          	auipc	ra,0xfffff
    80004232:	bac080e7          	jalr	-1108(ra) # 80002dda <bread>
    80004236:	892a                	mv	s2,a0
      if(either_copyin(bp->data, 0, (uint64)&newbtn, sizeof(struct btreenode)) == -1) {
    80004238:	26c00693          	li	a3,620
    8000423c:	d5040613          	addi	a2,s0,-688
    80004240:	4581                	li	a1,0
    80004242:	05850513          	addi	a0,a0,88
    80004246:	ffffe097          	auipc	ra,0xffffe
    8000424a:	22c080e7          	jalr	556(ra) # 80002472 <either_copyin>
    8000424e:	84aa                	mv	s1,a0
    80004250:	57fd                	li	a5,-1
    80004252:	0af50163          	beq	a0,a5,800042f4 <btninsert+0x48c>
      log_write(bp);
    80004256:	854a                	mv	a0,s2
    80004258:	00001097          	auipc	ra,0x1
    8000425c:	816080e7          	jalr	-2026(ra) # 80004a6e <log_write>
      brelse(bp);
    80004260:	854a                	mv	a0,s2
    80004262:	fffff097          	auipc	ra,0xfffff
    80004266:	ca8080e7          	jalr	-856(ra) # 80002f0a <brelse>
      bp = bread(ip->dev, rbtn.block);
    8000426a:	d4842583          	lw	a1,-696(s0)
    8000426e:	000a2503          	lw	a0,0(s4)
    80004272:	fffff097          	auipc	ra,0xfffff
    80004276:	b68080e7          	jalr	-1176(ra) # 80002dda <bread>
    8000427a:	892a                	mv	s2,a0
      if(either_copyin(bp->data, 0, (uint64)&rbtn, sizeof(struct btreenode)) == -1) {
    8000427c:	26c00693          	li	a3,620
    80004280:	ae040613          	addi	a2,s0,-1312
    80004284:	4581                	li	a1,0
    80004286:	05850513          	addi	a0,a0,88
    8000428a:	ffffe097          	auipc	ra,0xffffe
    8000428e:	1e8080e7          	jalr	488(ra) # 80002472 <either_copyin>
    80004292:	84aa                	mv	s1,a0
    80004294:	57fd                	li	a5,-1
    80004296:	06f50563          	beq	a0,a5,80004300 <btninsert+0x498>
      log_write(bp);
    8000429a:	854a                	mv	a0,s2
    8000429c:	00000097          	auipc	ra,0x0
    800042a0:	7d2080e7          	jalr	2002(ra) # 80004a6e <log_write>
      brelse(bp);
    800042a4:	854a                	mv	a0,s2
    800042a6:	fffff097          	auipc	ra,0xfffff
    800042aa:	c64080e7          	jalr	-924(ra) # 80002f0a <brelse>
      bp = bread(ip->dev, lbtn->block);
    800042ae:	2689a583          	lw	a1,616(s3)
    800042b2:	000a2503          	lw	a0,0(s4)
    800042b6:	fffff097          	auipc	ra,0xfffff
    800042ba:	b24080e7          	jalr	-1244(ra) # 80002dda <bread>
    800042be:	892a                	mv	s2,a0
      if(either_copyin(bp->data, 0, (uint64)lbtn, sizeof(struct btreenode)) == -1) {
    800042c0:	26c00693          	li	a3,620
    800042c4:	864e                	mv	a2,s3
    800042c6:	4581                	li	a1,0
    800042c8:	05850513          	addi	a0,a0,88
    800042cc:	ffffe097          	auipc	ra,0xffffe
    800042d0:	1a6080e7          	jalr	422(ra) # 80002472 <either_copyin>
    800042d4:	84aa                	mv	s1,a0
    800042d6:	57fd                	li	a5,-1
    800042d8:	02f50a63          	beq	a0,a5,8000430c <btninsert+0x4a4>
      log_write(bp);
    800042dc:	854a                	mv	a0,s2
    800042de:	00000097          	auipc	ra,0x0
    800042e2:	790080e7          	jalr	1936(ra) # 80004a6e <log_write>
      brelse(bp);
    800042e6:	854a                	mv	a0,s2
    800042e8:	fffff097          	auipc	ra,0xfffff
    800042ec:	c22080e7          	jalr	-990(ra) # 80002f0a <brelse>
      return 0;
    800042f0:	4481                	li	s1,0
    800042f2:	b159                	j	80003f78 <btninsert+0x110>
        brelse(bp);
    800042f4:	854a                	mv	a0,s2
    800042f6:	fffff097          	auipc	ra,0xfffff
    800042fa:	c14080e7          	jalr	-1004(ra) # 80002f0a <brelse>
        return -1;
    800042fe:	b9ad                	j	80003f78 <btninsert+0x110>
        brelse(bp);
    80004300:	854a                	mv	a0,s2
    80004302:	fffff097          	auipc	ra,0xfffff
    80004306:	c08080e7          	jalr	-1016(ra) # 80002f0a <brelse>
        return -1;
    8000430a:	b1bd                	j	80003f78 <btninsert+0x110>
        brelse(bp);
    8000430c:	854a                	mv	a0,s2
    8000430e:	fffff097          	auipc	ra,0xfffff
    80004312:	bfc080e7          	jalr	-1028(ra) # 80002f0a <brelse>
        return -1;
    80004316:	b18d                	j	80003f78 <btninsert+0x110>
        brelse(bp);
    80004318:	855a                	mv	a0,s6
    8000431a:	fffff097          	auipc	ra,0xfffff
    8000431e:	bf0080e7          	jalr	-1040(ra) # 80002f0a <brelse>
        return -1;
    80004322:	54fd                	li	s1,-1
    80004324:	b991                	j	80003f78 <btninsert+0x110>
        brelse(bp);
    80004326:	855a                	mv	a0,s6
    80004328:	fffff097          	auipc	ra,0xfffff
    8000432c:	be2080e7          	jalr	-1054(ra) # 80002f0a <brelse>
        return -1;
    80004330:	bfcd                	j	80004322 <btninsert+0x4ba>
      brelse(bp);
    80004332:	854a                	mv	a0,s2
    80004334:	fffff097          	auipc	ra,0xfffff
    80004338:	bd6080e7          	jalr	-1066(ra) # 80002f0a <brelse>
      return -1;
    8000433c:	b935                	j	80003f78 <btninsert+0x110>

000000008000433e <dirlookup>:

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
{
    8000433e:	d4010113          	addi	sp,sp,-704
    80004342:	2a113c23          	sd	ra,696(sp)
    80004346:	2a813823          	sd	s0,688(sp)
    8000434a:	2a913423          	sd	s1,680(sp)
    8000434e:	2b213023          	sd	s2,672(sp)
    80004352:	29313c23          	sd	s3,664(sp)
    80004356:	29413823          	sd	s4,656(sp)
    8000435a:	29513423          	sd	s5,648(sp)
    8000435e:	29613023          	sd	s6,640(sp)
    80004362:	27713c23          	sd	s7,632(sp)
    80004366:	0580                	addi	s0,sp,704
  // 根据name在dp的B树中查找对应的目录项
  uint blocknum;
  struct btreenode btn;
  struct buf *bp;
  // B树根节点所在块号
  blocknum = dp->addrs[0];
    80004368:	05052b03          	lw	s6,80(a0)
  // 找不到该目录的btree根结点
  if(blocknum == 0){
    8000436c:	0c0b0a63          	beqz	s6,80004440 <dirlookup+0x102>
    80004370:	8aaa                	mv	s5,a0
    80004372:	8a2e                	mv	s4,a1
    // 根据块号找结点
    bp = bread(dp->dev, blocknum);
    memmove(&btn, bp->data, sizeof(struct btreenode));
    brelse(bp);
    // 在这个节点中比较
    int i = 0;
    80004374:	4b81                	li	s7,0
    80004376:	a095                	j	800043da <dirlookup+0x9c>
    for(; i < btn.numkeys; i++){
      int res = namecmp(name, btn.keys[i].name);
      if(res == 0){                             // name == keys[i].name
        return iget(dp->dev, btn.keys[i].inum); // 成功找到对应目录项
    80004378:	00499793          	slli	a5,s3,0x4
    8000437c:	fb078793          	addi	a5,a5,-80
    80004380:	97a2                	add	a5,a5,s0
    80004382:	d9c7d583          	lhu	a1,-612(a5)
    80004386:	000aa503          	lw	a0,0(s5)
    8000438a:	fffff097          	auipc	ra,0xfffff
    8000438e:	fe4080e7          	jalr	-28(ra) # 8000336e <iget>
    // 继续寻找对应的子节点
    if(i == btn.numkeys) blocknum = btn.children[i];
  }

  return 0;
}
    80004392:	2b813083          	ld	ra,696(sp)
    80004396:	2b013403          	ld	s0,688(sp)
    8000439a:	2a813483          	ld	s1,680(sp)
    8000439e:	2a013903          	ld	s2,672(sp)
    800043a2:	29813983          	ld	s3,664(sp)
    800043a6:	29013a03          	ld	s4,656(sp)
    800043aa:	28813a83          	ld	s5,648(sp)
    800043ae:	28013b03          	ld	s6,640(sp)
    800043b2:	27813b83          	ld	s7,632(sp)
    800043b6:	2c010113          	addi	sp,sp,704
    800043ba:	8082                	ret
        blocknum = btn.children[i];
    800043bc:	07898793          	addi	a5,s3,120
    800043c0:	078a                	slli	a5,a5,0x2
    800043c2:	fb078793          	addi	a5,a5,-80
    800043c6:	97a2                	add	a5,a5,s0
    800043c8:	d9c7ab03          	lw	s6,-612(a5)
    if(btn.isleaf) return 0;
    800043cc:	d4042783          	lw	a5,-704(s0)
    800043d0:	ebb5                	bnez	a5,80004444 <dirlookup+0x106>
    if(i == btn.numkeys) blocknum = btn.children[i];
    800043d2:	d4442783          	lw	a5,-700(s0)
    800043d6:	06978f63          	beq	a5,s1,80004454 <dirlookup+0x116>
    bp = bread(dp->dev, blocknum);
    800043da:	85da                	mv	a1,s6
    800043dc:	000aa503          	lw	a0,0(s5)
    800043e0:	fffff097          	auipc	ra,0xfffff
    800043e4:	9fa080e7          	jalr	-1542(ra) # 80002dda <bread>
    800043e8:	84aa                	mv	s1,a0
    memmove(&btn, bp->data, sizeof(struct btreenode));
    800043ea:	26c00613          	li	a2,620
    800043ee:	05850593          	addi	a1,a0,88
    800043f2:	d4040513          	addi	a0,s0,-704
    800043f6:	ffffd097          	auipc	ra,0xffffd
    800043fa:	924080e7          	jalr	-1756(ra) # 80000d1a <memmove>
    brelse(bp);
    800043fe:	8526                	mv	a0,s1
    80004400:	fffff097          	auipc	ra,0xfffff
    80004404:	b0a080e7          	jalr	-1270(ra) # 80002f0a <brelse>
    for(; i < btn.numkeys; i++){
    80004408:	d4442783          	lw	a5,-700(s0)
    8000440c:	c3a1                	beqz	a5,8000444c <dirlookup+0x10e>
    8000440e:	d4e40913          	addi	s2,s0,-690
    int i = 0;
    80004412:	89de                	mv	s3,s7
    80004414:	0009849b          	sext.w	s1,s3
      int res = namecmp(name, btn.keys[i].name);
    80004418:	85ca                	mv	a1,s2
    8000441a:	8552                	mv	a0,s4
    8000441c:	fffff097          	auipc	ra,0xfffff
    80004420:	7fa080e7          	jalr	2042(ra) # 80003c16 <namecmp>
      if(res == 0){                             // name == keys[i].name
    80004424:	d931                	beqz	a0,80004378 <dirlookup+0x3a>
      }else if(res < 0){                        // name < b.keys[i].name
    80004426:	f8054be3          	bltz	a0,800043bc <dirlookup+0x7e>
    for(; i < btn.numkeys; i++){
    8000442a:	0019849b          	addiw	s1,s3,1
    8000442e:	0004899b          	sext.w	s3,s1
    80004432:	84ce                	mv	s1,s3
    80004434:	0941                	addi	s2,s2,16
    80004436:	d4442783          	lw	a5,-700(s0)
    8000443a:	fcf9ede3          	bltu	s3,a5,80004414 <dirlookup+0xd6>
    8000443e:	b779                	j	800043cc <dirlookup+0x8e>
    return 0;
    80004440:	4501                	li	a0,0
    80004442:	bf81                	j	80004392 <dirlookup+0x54>
    if(btn.isleaf) return 0;
    80004444:	4501                	li	a0,0
    80004446:	b7b1                	j	80004392 <dirlookup+0x54>
    80004448:	4501                	li	a0,0
    8000444a:	b7a1                	j	80004392 <dirlookup+0x54>
    8000444c:	d4042783          	lw	a5,-704(s0)
    80004450:	ffe5                	bnez	a5,80004448 <dirlookup+0x10a>
    int i = 0;
    80004452:	89de                	mv	s3,s7
    if(i == btn.numkeys) blocknum = btn.children[i];
    80004454:	07898793          	addi	a5,s3,120
    80004458:	078a                	slli	a5,a5,0x2
    8000445a:	fb078793          	addi	a5,a5,-80
    8000445e:	97a2                	add	a5,a5,s0
    80004460:	d9c7ab03          	lw	s6,-612(a5)
    80004464:	bf9d                	j	800043da <dirlookup+0x9c>

0000000080004466 <namex>:
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
// Must be called inside a transaction since it calls iput().
static struct inode*
namex(char *path, int nameiparent, char *name)
{
    80004466:	711d                	addi	sp,sp,-96
    80004468:	ec86                	sd	ra,88(sp)
    8000446a:	e8a2                	sd	s0,80(sp)
    8000446c:	e4a6                	sd	s1,72(sp)
    8000446e:	e0ca                	sd	s2,64(sp)
    80004470:	fc4e                	sd	s3,56(sp)
    80004472:	f852                	sd	s4,48(sp)
    80004474:	f456                	sd	s5,40(sp)
    80004476:	f05a                	sd	s6,32(sp)
    80004478:	ec5e                	sd	s7,24(sp)
    8000447a:	e862                	sd	s8,16(sp)
    8000447c:	e466                	sd	s9,8(sp)
    8000447e:	e06a                	sd	s10,0(sp)
    80004480:	1080                	addi	s0,sp,96
    80004482:	84aa                	mv	s1,a0
    80004484:	8b2e                	mv	s6,a1
    80004486:	8ab2                	mv	s5,a2
  struct inode *ip, *next;

  if(*path == '/')
    80004488:	00054703          	lbu	a4,0(a0)
    8000448c:	02f00793          	li	a5,47
    80004490:	02f70363          	beq	a4,a5,800044b6 <namex+0x50>
    ip = iget(ROOTDEV, ROOTINO);
  else
    ip = idup(myproc()->cwd);
    80004494:	ffffd097          	auipc	ra,0xffffd
    80004498:	516080e7          	jalr	1302(ra) # 800019aa <myproc>
    8000449c:	15053503          	ld	a0,336(a0)
    800044a0:	fffff097          	auipc	ra,0xfffff
    800044a4:	1c6080e7          	jalr	454(ra) # 80003666 <idup>
    800044a8:	8a2a                	mv	s4,a0
  while(*path == '/')
    800044aa:	02f00913          	li	s2,47
  if(len >= DIRSIZ)
    800044ae:	4cb5                	li	s9,13
  len = path - s;
    800044b0:	4b81                	li	s7,0

  while((path = skipelem(path, name)) != 0){
    ilock(ip);
    if(ip->type != T_DIR){
    800044b2:	4c05                	li	s8,1
    800044b4:	a87d                	j	80004572 <namex+0x10c>
    ip = iget(ROOTDEV, ROOTINO);
    800044b6:	4585                	li	a1,1
    800044b8:	4505                	li	a0,1
    800044ba:	fffff097          	auipc	ra,0xfffff
    800044be:	eb4080e7          	jalr	-332(ra) # 8000336e <iget>
    800044c2:	8a2a                	mv	s4,a0
    800044c4:	b7dd                	j	800044aa <namex+0x44>
      iunlockput(ip);
    800044c6:	8552                	mv	a0,s4
    800044c8:	fffff097          	auipc	ra,0xfffff
    800044cc:	4e4080e7          	jalr	1252(ra) # 800039ac <iunlockput>
      return 0;
    800044d0:	4a01                	li	s4,0
  if(nameiparent){
    iput(ip);
    return 0;
  }
  return ip;
}
    800044d2:	8552                	mv	a0,s4
    800044d4:	60e6                	ld	ra,88(sp)
    800044d6:	6446                	ld	s0,80(sp)
    800044d8:	64a6                	ld	s1,72(sp)
    800044da:	6906                	ld	s2,64(sp)
    800044dc:	79e2                	ld	s3,56(sp)
    800044de:	7a42                	ld	s4,48(sp)
    800044e0:	7aa2                	ld	s5,40(sp)
    800044e2:	7b02                	ld	s6,32(sp)
    800044e4:	6be2                	ld	s7,24(sp)
    800044e6:	6c42                	ld	s8,16(sp)
    800044e8:	6ca2                	ld	s9,8(sp)
    800044ea:	6d02                	ld	s10,0(sp)
    800044ec:	6125                	addi	sp,sp,96
    800044ee:	8082                	ret
      iunlock(ip);
    800044f0:	8552                	mv	a0,s4
    800044f2:	fffff097          	auipc	ra,0xfffff
    800044f6:	274080e7          	jalr	628(ra) # 80003766 <iunlock>
      return ip;
    800044fa:	bfe1                	j	800044d2 <namex+0x6c>
      iunlockput(ip);
    800044fc:	8552                	mv	a0,s4
    800044fe:	fffff097          	auipc	ra,0xfffff
    80004502:	4ae080e7          	jalr	1198(ra) # 800039ac <iunlockput>
      return 0;
    80004506:	8a4e                	mv	s4,s3
    80004508:	b7e9                	j	800044d2 <namex+0x6c>
  len = path - s;
    8000450a:	40998633          	sub	a2,s3,s1
    8000450e:	00060d1b          	sext.w	s10,a2
  if(len >= DIRSIZ)
    80004512:	09acd863          	bge	s9,s10,800045a2 <namex+0x13c>
    memmove(name, s, DIRSIZ);
    80004516:	4639                	li	a2,14
    80004518:	85a6                	mv	a1,s1
    8000451a:	8556                	mv	a0,s5
    8000451c:	ffffc097          	auipc	ra,0xffffc
    80004520:	7fe080e7          	jalr	2046(ra) # 80000d1a <memmove>
    80004524:	84ce                	mv	s1,s3
  while(*path == '/')
    80004526:	0004c783          	lbu	a5,0(s1)
    8000452a:	01279763          	bne	a5,s2,80004538 <namex+0xd2>
    path++;
    8000452e:	0485                	addi	s1,s1,1
  while(*path == '/')
    80004530:	0004c783          	lbu	a5,0(s1)
    80004534:	ff278de3          	beq	a5,s2,8000452e <namex+0xc8>
    ilock(ip);
    80004538:	8552                	mv	a0,s4
    8000453a:	fffff097          	auipc	ra,0xfffff
    8000453e:	16a080e7          	jalr	362(ra) # 800036a4 <ilock>
    if(ip->type != T_DIR){
    80004542:	044a1783          	lh	a5,68(s4)
    80004546:	f98790e3          	bne	a5,s8,800044c6 <namex+0x60>
    if(nameiparent && *path == '\0'){
    8000454a:	000b0563          	beqz	s6,80004554 <namex+0xee>
    8000454e:	0004c783          	lbu	a5,0(s1)
    80004552:	dfd9                	beqz	a5,800044f0 <namex+0x8a>
    if((next = dirlookup(ip, name, 0)) == 0){
    80004554:	865e                	mv	a2,s7
    80004556:	85d6                	mv	a1,s5
    80004558:	8552                	mv	a0,s4
    8000455a:	00000097          	auipc	ra,0x0
    8000455e:	de4080e7          	jalr	-540(ra) # 8000433e <dirlookup>
    80004562:	89aa                	mv	s3,a0
    80004564:	dd41                	beqz	a0,800044fc <namex+0x96>
    iunlockput(ip);
    80004566:	8552                	mv	a0,s4
    80004568:	fffff097          	auipc	ra,0xfffff
    8000456c:	444080e7          	jalr	1092(ra) # 800039ac <iunlockput>
    ip = next;
    80004570:	8a4e                	mv	s4,s3
  while(*path == '/')
    80004572:	0004c783          	lbu	a5,0(s1)
    80004576:	01279763          	bne	a5,s2,80004584 <namex+0x11e>
    path++;
    8000457a:	0485                	addi	s1,s1,1
  while(*path == '/')
    8000457c:	0004c783          	lbu	a5,0(s1)
    80004580:	ff278de3          	beq	a5,s2,8000457a <namex+0x114>
  if(*path == 0)
    80004584:	cb9d                	beqz	a5,800045ba <namex+0x154>
  while(*path != '/' && *path != 0)
    80004586:	0004c783          	lbu	a5,0(s1)
    8000458a:	89a6                	mv	s3,s1
  len = path - s;
    8000458c:	8d5e                	mv	s10,s7
    8000458e:	865e                	mv	a2,s7
  while(*path != '/' && *path != 0)
    80004590:	01278963          	beq	a5,s2,800045a2 <namex+0x13c>
    80004594:	dbbd                	beqz	a5,8000450a <namex+0xa4>
    path++;
    80004596:	0985                	addi	s3,s3,1
  while(*path != '/' && *path != 0)
    80004598:	0009c783          	lbu	a5,0(s3)
    8000459c:	ff279ce3          	bne	a5,s2,80004594 <namex+0x12e>
    800045a0:	b7ad                	j	8000450a <namex+0xa4>
    memmove(name, s, len);
    800045a2:	2601                	sext.w	a2,a2
    800045a4:	85a6                	mv	a1,s1
    800045a6:	8556                	mv	a0,s5
    800045a8:	ffffc097          	auipc	ra,0xffffc
    800045ac:	772080e7          	jalr	1906(ra) # 80000d1a <memmove>
    name[len] = 0;
    800045b0:	9d56                	add	s10,s10,s5
    800045b2:	000d0023          	sb	zero,0(s10)
    800045b6:	84ce                	mv	s1,s3
    800045b8:	b7bd                	j	80004526 <namex+0xc0>
  if(nameiparent){
    800045ba:	f00b0ce3          	beqz	s6,800044d2 <namex+0x6c>
    iput(ip);
    800045be:	8552                	mv	a0,s4
    800045c0:	fffff097          	auipc	ra,0xfffff
    800045c4:	344080e7          	jalr	836(ra) # 80003904 <iput>
    return 0;
    800045c8:	4a01                	li	s4,0
    800045ca:	b721                	j	800044d2 <namex+0x6c>

00000000800045cc <dirlink>:
{
    800045cc:	d3010113          	addi	sp,sp,-720
    800045d0:	2c113423          	sd	ra,712(sp)
    800045d4:	2c813023          	sd	s0,704(sp)
    800045d8:	2a913c23          	sd	s1,696(sp)
    800045dc:	2b213823          	sd	s2,688(sp)
    800045e0:	0d80                	addi	s0,sp,720
    800045e2:	84aa                	mv	s1,a0
    800045e4:	892e                	mv	s2,a1
  for(int i = 0; i < NBTN; i++) btt.btstack[i] = 0;
    800045e6:	d4040793          	addi	a5,s0,-704
    800045ea:	d6840713          	addi	a4,s0,-664
    800045ee:	0007a023          	sw	zero,0(a5)
    800045f2:	0791                	addi	a5,a5,4
    800045f4:	fee79de3          	bne	a5,a4,800045ee <dirlink+0x22>
  btt.stacktop = 0;
    800045f8:	d6042423          	sw	zero,-664(s0)
  de.inum = inum;
    800045fc:	d2c41823          	sh	a2,-720(s0)
  strncpy(de.name, name, DIRSIZ);
    80004600:	4639                	li	a2,14
    80004602:	85ca                	mv	a1,s2
    80004604:	d3240513          	addi	a0,s0,-718
    80004608:	ffffc097          	auipc	ra,0xffffc
    8000460c:	7ca080e7          	jalr	1994(ra) # 80000dd2 <strncpy>
  if(btnfind(&btn, dp, &btt, name) < 0) {
    80004610:	86ca                	mv	a3,s2
    80004612:	d4040613          	addi	a2,s0,-704
    80004616:	85a6                	mv	a1,s1
    80004618:	d7040513          	addi	a0,s0,-656
    8000461c:	fffff097          	auipc	ra,0xfffff
    80004620:	6bc080e7          	jalr	1724(ra) # 80003cd8 <btnfind>
    80004624:	04054863          	bltz	a0,80004674 <dirlink+0xa8>
  if(btt.stacktop != 0)btt.stacktop--;
    80004628:	d6842783          	lw	a5,-664(s0)
    8000462c:	c781                	beqz	a5,80004634 <dirlink+0x68>
    8000462e:	37fd                	addiw	a5,a5,-1
    80004630:	d6f42423          	sw	a5,-664(s0)
  btninsert(&btn, dp, &btt, &de, findsuiteindex(&btn, &de));
    80004634:	d3040593          	addi	a1,s0,-720
    80004638:	d7040513          	addi	a0,s0,-656
    8000463c:	fffff097          	auipc	ra,0xfffff
    80004640:	7d4080e7          	jalr	2004(ra) # 80003e10 <findsuiteindex>
    80004644:	872a                	mv	a4,a0
    80004646:	d3040693          	addi	a3,s0,-720
    8000464a:	d4040613          	addi	a2,s0,-704
    8000464e:	85a6                	mv	a1,s1
    80004650:	d7040513          	addi	a0,s0,-656
    80004654:	00000097          	auipc	ra,0x0
    80004658:	814080e7          	jalr	-2028(ra) # 80003e68 <btninsert>
  return 0;
    8000465c:	4501                	li	a0,0
}
    8000465e:	2c813083          	ld	ra,712(sp)
    80004662:	2c013403          	ld	s0,704(sp)
    80004666:	2b813483          	ld	s1,696(sp)
    8000466a:	2b013903          	ld	s2,688(sp)
    8000466e:	2d010113          	addi	sp,sp,720
    80004672:	8082                	ret
    return -1;
    80004674:	557d                	li	a0,-1
    80004676:	b7e5                	j	8000465e <dirlink+0x92>

0000000080004678 <namei>:

struct inode*
namei(char *path)
{
    80004678:	1101                	addi	sp,sp,-32
    8000467a:	ec06                	sd	ra,24(sp)
    8000467c:	e822                	sd	s0,16(sp)
    8000467e:	1000                	addi	s0,sp,32
  char name[DIRSIZ];
  return namex(path, 0, name);
    80004680:	fe040613          	addi	a2,s0,-32
    80004684:	4581                	li	a1,0
    80004686:	00000097          	auipc	ra,0x0
    8000468a:	de0080e7          	jalr	-544(ra) # 80004466 <namex>
}
    8000468e:	60e2                	ld	ra,24(sp)
    80004690:	6442                	ld	s0,16(sp)
    80004692:	6105                	addi	sp,sp,32
    80004694:	8082                	ret

0000000080004696 <nameiparent>:

struct inode*
nameiparent(char *path, char *name)
{
    80004696:	1141                	addi	sp,sp,-16
    80004698:	e406                	sd	ra,8(sp)
    8000469a:	e022                	sd	s0,0(sp)
    8000469c:	0800                	addi	s0,sp,16
    8000469e:	862e                	mv	a2,a1
  return namex(path, 1, name);
    800046a0:	4585                	li	a1,1
    800046a2:	00000097          	auipc	ra,0x0
    800046a6:	dc4080e7          	jalr	-572(ra) # 80004466 <namex>
}
    800046aa:	60a2                	ld	ra,8(sp)
    800046ac:	6402                	ld	s0,0(sp)
    800046ae:	0141                	addi	sp,sp,16
    800046b0:	8082                	ret

00000000800046b2 <write_head>:
// Write in-memory log header to disk.
// This is the true point at which the
// current transaction commits.
static void
write_head(void)
{
    800046b2:	1101                	addi	sp,sp,-32
    800046b4:	ec06                	sd	ra,24(sp)
    800046b6:	e822                	sd	s0,16(sp)
    800046b8:	e426                	sd	s1,8(sp)
    800046ba:	e04a                	sd	s2,0(sp)
    800046bc:	1000                	addi	s0,sp,32
  struct buf *buf = bread(log.dev, log.start);
    800046be:	00018917          	auipc	s2,0x18
    800046c2:	faa90913          	addi	s2,s2,-86 # 8001c668 <log>
    800046c6:	01892583          	lw	a1,24(s2)
    800046ca:	02892503          	lw	a0,40(s2)
    800046ce:	ffffe097          	auipc	ra,0xffffe
    800046d2:	70c080e7          	jalr	1804(ra) # 80002dda <bread>
    800046d6:	84aa                	mv	s1,a0
  struct logheader *hb = (struct logheader *) (buf->data);
  int i;
  hb->n = log.lh.n;
    800046d8:	02c92683          	lw	a3,44(s2)
    800046dc:	cd34                	sw	a3,88(a0)
  for (i = 0; i < log.lh.n; i++) {
    800046de:	02d05863          	blez	a3,8000470e <write_head+0x5c>
    800046e2:	00018797          	auipc	a5,0x18
    800046e6:	fb678793          	addi	a5,a5,-74 # 8001c698 <log+0x30>
    800046ea:	05c50713          	addi	a4,a0,92
    800046ee:	36fd                	addiw	a3,a3,-1
    800046f0:	02069613          	slli	a2,a3,0x20
    800046f4:	01e65693          	srli	a3,a2,0x1e
    800046f8:	00018617          	auipc	a2,0x18
    800046fc:	fa460613          	addi	a2,a2,-92 # 8001c69c <log+0x34>
    80004700:	96b2                	add	a3,a3,a2
    hb->block[i] = log.lh.block[i];
    80004702:	4390                	lw	a2,0(a5)
    80004704:	c310                	sw	a2,0(a4)
  for (i = 0; i < log.lh.n; i++) {
    80004706:	0791                	addi	a5,a5,4
    80004708:	0711                	addi	a4,a4,4
    8000470a:	fed79ce3          	bne	a5,a3,80004702 <write_head+0x50>
  }
  bwrite(buf);
    8000470e:	8526                	mv	a0,s1
    80004710:	ffffe097          	auipc	ra,0xffffe
    80004714:	7bc080e7          	jalr	1980(ra) # 80002ecc <bwrite>
  brelse(buf);
    80004718:	8526                	mv	a0,s1
    8000471a:	ffffe097          	auipc	ra,0xffffe
    8000471e:	7f0080e7          	jalr	2032(ra) # 80002f0a <brelse>
}
    80004722:	60e2                	ld	ra,24(sp)
    80004724:	6442                	ld	s0,16(sp)
    80004726:	64a2                	ld	s1,8(sp)
    80004728:	6902                	ld	s2,0(sp)
    8000472a:	6105                	addi	sp,sp,32
    8000472c:	8082                	ret

000000008000472e <install_trans>:
  for (tail = 0; tail < log.lh.n; tail++) {
    8000472e:	00018797          	auipc	a5,0x18
    80004732:	f667a783          	lw	a5,-154(a5) # 8001c694 <log+0x2c>
    80004736:	0af05d63          	blez	a5,800047f0 <install_trans+0xc2>
{
    8000473a:	7139                	addi	sp,sp,-64
    8000473c:	fc06                	sd	ra,56(sp)
    8000473e:	f822                	sd	s0,48(sp)
    80004740:	f426                	sd	s1,40(sp)
    80004742:	f04a                	sd	s2,32(sp)
    80004744:	ec4e                	sd	s3,24(sp)
    80004746:	e852                	sd	s4,16(sp)
    80004748:	e456                	sd	s5,8(sp)
    8000474a:	e05a                	sd	s6,0(sp)
    8000474c:	0080                	addi	s0,sp,64
    8000474e:	8b2a                	mv	s6,a0
    80004750:	00018a97          	auipc	s5,0x18
    80004754:	f48a8a93          	addi	s5,s5,-184 # 8001c698 <log+0x30>
  for (tail = 0; tail < log.lh.n; tail++) {
    80004758:	4a01                	li	s4,0
    struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
    8000475a:	00018997          	auipc	s3,0x18
    8000475e:	f0e98993          	addi	s3,s3,-242 # 8001c668 <log>
    80004762:	a00d                	j	80004784 <install_trans+0x56>
    brelse(lbuf);
    80004764:	854a                	mv	a0,s2
    80004766:	ffffe097          	auipc	ra,0xffffe
    8000476a:	7a4080e7          	jalr	1956(ra) # 80002f0a <brelse>
    brelse(dbuf);
    8000476e:	8526                	mv	a0,s1
    80004770:	ffffe097          	auipc	ra,0xffffe
    80004774:	79a080e7          	jalr	1946(ra) # 80002f0a <brelse>
  for (tail = 0; tail < log.lh.n; tail++) {
    80004778:	2a05                	addiw	s4,s4,1
    8000477a:	0a91                	addi	s5,s5,4
    8000477c:	02c9a783          	lw	a5,44(s3)
    80004780:	04fa5e63          	bge	s4,a5,800047dc <install_trans+0xae>
    struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
    80004784:	0189a583          	lw	a1,24(s3)
    80004788:	014585bb          	addw	a1,a1,s4
    8000478c:	2585                	addiw	a1,a1,1
    8000478e:	0289a503          	lw	a0,40(s3)
    80004792:	ffffe097          	auipc	ra,0xffffe
    80004796:	648080e7          	jalr	1608(ra) # 80002dda <bread>
    8000479a:	892a                	mv	s2,a0
    struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst
    8000479c:	000aa583          	lw	a1,0(s5)
    800047a0:	0289a503          	lw	a0,40(s3)
    800047a4:	ffffe097          	auipc	ra,0xffffe
    800047a8:	636080e7          	jalr	1590(ra) # 80002dda <bread>
    800047ac:	84aa                	mv	s1,a0
    memmove(dbuf->data, lbuf->data, BSIZE);  // copy block to dst
    800047ae:	40000613          	li	a2,1024
    800047b2:	05890593          	addi	a1,s2,88
    800047b6:	05850513          	addi	a0,a0,88
    800047ba:	ffffc097          	auipc	ra,0xffffc
    800047be:	560080e7          	jalr	1376(ra) # 80000d1a <memmove>
    bwrite(dbuf);  // write dst to disk
    800047c2:	8526                	mv	a0,s1
    800047c4:	ffffe097          	auipc	ra,0xffffe
    800047c8:	708080e7          	jalr	1800(ra) # 80002ecc <bwrite>
    if(recovering == 0)
    800047cc:	f80b1ce3          	bnez	s6,80004764 <install_trans+0x36>
      bunpin(dbuf);
    800047d0:	8526                	mv	a0,s1
    800047d2:	fffff097          	auipc	ra,0xfffff
    800047d6:	812080e7          	jalr	-2030(ra) # 80002fe4 <bunpin>
    800047da:	b769                	j	80004764 <install_trans+0x36>
}
    800047dc:	70e2                	ld	ra,56(sp)
    800047de:	7442                	ld	s0,48(sp)
    800047e0:	74a2                	ld	s1,40(sp)
    800047e2:	7902                	ld	s2,32(sp)
    800047e4:	69e2                	ld	s3,24(sp)
    800047e6:	6a42                	ld	s4,16(sp)
    800047e8:	6aa2                	ld	s5,8(sp)
    800047ea:	6b02                	ld	s6,0(sp)
    800047ec:	6121                	addi	sp,sp,64
    800047ee:	8082                	ret
    800047f0:	8082                	ret

00000000800047f2 <initlog>:
{
    800047f2:	7179                	addi	sp,sp,-48
    800047f4:	f406                	sd	ra,40(sp)
    800047f6:	f022                	sd	s0,32(sp)
    800047f8:	ec26                	sd	s1,24(sp)
    800047fa:	e84a                	sd	s2,16(sp)
    800047fc:	e44e                	sd	s3,8(sp)
    800047fe:	1800                	addi	s0,sp,48
    80004800:	892a                	mv	s2,a0
    80004802:	89ae                	mv	s3,a1
  initlock(&log.lock, "log");
    80004804:	00018497          	auipc	s1,0x18
    80004808:	e6448493          	addi	s1,s1,-412 # 8001c668 <log>
    8000480c:	00004597          	auipc	a1,0x4
    80004810:	dc458593          	addi	a1,a1,-572 # 800085d0 <syscalls+0x1b0>
    80004814:	8526                	mv	a0,s1
    80004816:	ffffc097          	auipc	ra,0xffffc
    8000481a:	31c080e7          	jalr	796(ra) # 80000b32 <initlock>
  log.start = sb->logstart;
    8000481e:	0149a583          	lw	a1,20(s3)
    80004822:	cc8c                	sw	a1,24(s1)
  log.size = sb->nlog;
    80004824:	0109a783          	lw	a5,16(s3)
    80004828:	ccdc                	sw	a5,28(s1)
  log.dev = dev;
    8000482a:	0324a423          	sw	s2,40(s1)
  struct buf *buf = bread(log.dev, log.start);
    8000482e:	854a                	mv	a0,s2
    80004830:	ffffe097          	auipc	ra,0xffffe
    80004834:	5aa080e7          	jalr	1450(ra) # 80002dda <bread>
  log.lh.n = lh->n;
    80004838:	4d34                	lw	a3,88(a0)
    8000483a:	d4d4                	sw	a3,44(s1)
  for (i = 0; i < log.lh.n; i++) {
    8000483c:	02d05663          	blez	a3,80004868 <initlog+0x76>
    80004840:	05c50793          	addi	a5,a0,92
    80004844:	00018717          	auipc	a4,0x18
    80004848:	e5470713          	addi	a4,a4,-428 # 8001c698 <log+0x30>
    8000484c:	36fd                	addiw	a3,a3,-1
    8000484e:	02069613          	slli	a2,a3,0x20
    80004852:	01e65693          	srli	a3,a2,0x1e
    80004856:	06050613          	addi	a2,a0,96
    8000485a:	96b2                	add	a3,a3,a2
    log.lh.block[i] = lh->block[i];
    8000485c:	4390                	lw	a2,0(a5)
    8000485e:	c310                	sw	a2,0(a4)
  for (i = 0; i < log.lh.n; i++) {
    80004860:	0791                	addi	a5,a5,4
    80004862:	0711                	addi	a4,a4,4
    80004864:	fed79ce3          	bne	a5,a3,8000485c <initlog+0x6a>
  brelse(buf);
    80004868:	ffffe097          	auipc	ra,0xffffe
    8000486c:	6a2080e7          	jalr	1698(ra) # 80002f0a <brelse>

static void
recover_from_log(void)
{
  read_head();
  install_trans(1); // if committed, copy from log to disk
    80004870:	4505                	li	a0,1
    80004872:	00000097          	auipc	ra,0x0
    80004876:	ebc080e7          	jalr	-324(ra) # 8000472e <install_trans>
  log.lh.n = 0;
    8000487a:	00018797          	auipc	a5,0x18
    8000487e:	e007ad23          	sw	zero,-486(a5) # 8001c694 <log+0x2c>
  write_head(); // clear the log
    80004882:	00000097          	auipc	ra,0x0
    80004886:	e30080e7          	jalr	-464(ra) # 800046b2 <write_head>
}
    8000488a:	70a2                	ld	ra,40(sp)
    8000488c:	7402                	ld	s0,32(sp)
    8000488e:	64e2                	ld	s1,24(sp)
    80004890:	6942                	ld	s2,16(sp)
    80004892:	69a2                	ld	s3,8(sp)
    80004894:	6145                	addi	sp,sp,48
    80004896:	8082                	ret

0000000080004898 <begin_op>:
}

// called at the start of each FS system call.
void
begin_op(void)
{
    80004898:	1101                	addi	sp,sp,-32
    8000489a:	ec06                	sd	ra,24(sp)
    8000489c:	e822                	sd	s0,16(sp)
    8000489e:	e426                	sd	s1,8(sp)
    800048a0:	e04a                	sd	s2,0(sp)
    800048a2:	1000                	addi	s0,sp,32
  acquire(&log.lock);
    800048a4:	00018517          	auipc	a0,0x18
    800048a8:	dc450513          	addi	a0,a0,-572 # 8001c668 <log>
    800048ac:	ffffc097          	auipc	ra,0xffffc
    800048b0:	316080e7          	jalr	790(ra) # 80000bc2 <acquire>
  while(1){
    if(log.committing){
    800048b4:	00018497          	auipc	s1,0x18
    800048b8:	db448493          	addi	s1,s1,-588 # 8001c668 <log>
      sleep(&log, &log.lock);
    } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    800048bc:	4979                	li	s2,30
    800048be:	a039                	j	800048cc <begin_op+0x34>
      sleep(&log, &log.lock);
    800048c0:	85a6                	mv	a1,s1
    800048c2:	8526                	mv	a0,s1
    800048c4:	ffffe097          	auipc	ra,0xffffe
    800048c8:	8fe080e7          	jalr	-1794(ra) # 800021c2 <sleep>
    if(log.committing){
    800048cc:	50dc                	lw	a5,36(s1)
    800048ce:	fbed                	bnez	a5,800048c0 <begin_op+0x28>
    } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    800048d0:	5098                	lw	a4,32(s1)
    800048d2:	2705                	addiw	a4,a4,1
    800048d4:	0007069b          	sext.w	a3,a4
    800048d8:	0027179b          	slliw	a5,a4,0x2
    800048dc:	9fb9                	addw	a5,a5,a4
    800048de:	0017979b          	slliw	a5,a5,0x1
    800048e2:	54d8                	lw	a4,44(s1)
    800048e4:	9fb9                	addw	a5,a5,a4
    800048e6:	00f95963          	bge	s2,a5,800048f8 <begin_op+0x60>
      // this op might exhaust log space; wait for commit.
      sleep(&log, &log.lock);
    800048ea:	85a6                	mv	a1,s1
    800048ec:	8526                	mv	a0,s1
    800048ee:	ffffe097          	auipc	ra,0xffffe
    800048f2:	8d4080e7          	jalr	-1836(ra) # 800021c2 <sleep>
    800048f6:	bfd9                	j	800048cc <begin_op+0x34>
    } else {
      log.outstanding += 1;
    800048f8:	00018517          	auipc	a0,0x18
    800048fc:	d7050513          	addi	a0,a0,-656 # 8001c668 <log>
    80004900:	d114                	sw	a3,32(a0)
      release(&log.lock);
    80004902:	ffffc097          	auipc	ra,0xffffc
    80004906:	374080e7          	jalr	884(ra) # 80000c76 <release>
      break;
    }
  }
}
    8000490a:	60e2                	ld	ra,24(sp)
    8000490c:	6442                	ld	s0,16(sp)
    8000490e:	64a2                	ld	s1,8(sp)
    80004910:	6902                	ld	s2,0(sp)
    80004912:	6105                	addi	sp,sp,32
    80004914:	8082                	ret

0000000080004916 <end_op>:

// called at the end of each FS system call.
// commits if this was the last outstanding operation.
void
end_op(void)
{
    80004916:	7139                	addi	sp,sp,-64
    80004918:	fc06                	sd	ra,56(sp)
    8000491a:	f822                	sd	s0,48(sp)
    8000491c:	f426                	sd	s1,40(sp)
    8000491e:	f04a                	sd	s2,32(sp)
    80004920:	ec4e                	sd	s3,24(sp)
    80004922:	e852                	sd	s4,16(sp)
    80004924:	e456                	sd	s5,8(sp)
    80004926:	0080                	addi	s0,sp,64
  int do_commit = 0;

  acquire(&log.lock);
    80004928:	00018497          	auipc	s1,0x18
    8000492c:	d4048493          	addi	s1,s1,-704 # 8001c668 <log>
    80004930:	8526                	mv	a0,s1
    80004932:	ffffc097          	auipc	ra,0xffffc
    80004936:	290080e7          	jalr	656(ra) # 80000bc2 <acquire>
  log.outstanding -= 1;
    8000493a:	509c                	lw	a5,32(s1)
    8000493c:	37fd                	addiw	a5,a5,-1
    8000493e:	0007891b          	sext.w	s2,a5
    80004942:	d09c                	sw	a5,32(s1)
  if(log.committing)
    80004944:	50dc                	lw	a5,36(s1)
    80004946:	e7b9                	bnez	a5,80004994 <end_op+0x7e>
    panic("log.committing");
  if(log.outstanding == 0){
    80004948:	04091e63          	bnez	s2,800049a4 <end_op+0x8e>
    do_commit = 1;
    log.committing = 1;
    8000494c:	00018497          	auipc	s1,0x18
    80004950:	d1c48493          	addi	s1,s1,-740 # 8001c668 <log>
    80004954:	4785                	li	a5,1
    80004956:	d0dc                	sw	a5,36(s1)
    // begin_op() may be waiting for log space,
    // and decrementing log.outstanding has decreased
    // the amount of reserved space.
    wakeup(&log);
  }
  release(&log.lock);
    80004958:	8526                	mv	a0,s1
    8000495a:	ffffc097          	auipc	ra,0xffffc
    8000495e:	31c080e7          	jalr	796(ra) # 80000c76 <release>
}

static void
commit()
{
  if (log.lh.n > 0) {
    80004962:	54dc                	lw	a5,44(s1)
    80004964:	06f04763          	bgtz	a5,800049d2 <end_op+0xbc>
    acquire(&log.lock);
    80004968:	00018497          	auipc	s1,0x18
    8000496c:	d0048493          	addi	s1,s1,-768 # 8001c668 <log>
    80004970:	8526                	mv	a0,s1
    80004972:	ffffc097          	auipc	ra,0xffffc
    80004976:	250080e7          	jalr	592(ra) # 80000bc2 <acquire>
    log.committing = 0;
    8000497a:	0204a223          	sw	zero,36(s1)
    wakeup(&log);
    8000497e:	8526                	mv	a0,s1
    80004980:	ffffe097          	auipc	ra,0xffffe
    80004984:	9c2080e7          	jalr	-1598(ra) # 80002342 <wakeup>
    release(&log.lock);
    80004988:	8526                	mv	a0,s1
    8000498a:	ffffc097          	auipc	ra,0xffffc
    8000498e:	2ec080e7          	jalr	748(ra) # 80000c76 <release>
}
    80004992:	a03d                	j	800049c0 <end_op+0xaa>
    panic("log.committing");
    80004994:	00004517          	auipc	a0,0x4
    80004998:	c4450513          	addi	a0,a0,-956 # 800085d8 <syscalls+0x1b8>
    8000499c:	ffffc097          	auipc	ra,0xffffc
    800049a0:	b90080e7          	jalr	-1136(ra) # 8000052c <panic>
    wakeup(&log);
    800049a4:	00018497          	auipc	s1,0x18
    800049a8:	cc448493          	addi	s1,s1,-828 # 8001c668 <log>
    800049ac:	8526                	mv	a0,s1
    800049ae:	ffffe097          	auipc	ra,0xffffe
    800049b2:	994080e7          	jalr	-1644(ra) # 80002342 <wakeup>
  release(&log.lock);
    800049b6:	8526                	mv	a0,s1
    800049b8:	ffffc097          	auipc	ra,0xffffc
    800049bc:	2be080e7          	jalr	702(ra) # 80000c76 <release>
}
    800049c0:	70e2                	ld	ra,56(sp)
    800049c2:	7442                	ld	s0,48(sp)
    800049c4:	74a2                	ld	s1,40(sp)
    800049c6:	7902                	ld	s2,32(sp)
    800049c8:	69e2                	ld	s3,24(sp)
    800049ca:	6a42                	ld	s4,16(sp)
    800049cc:	6aa2                	ld	s5,8(sp)
    800049ce:	6121                	addi	sp,sp,64
    800049d0:	8082                	ret
  for (tail = 0; tail < log.lh.n; tail++) {
    800049d2:	00018a97          	auipc	s5,0x18
    800049d6:	cc6a8a93          	addi	s5,s5,-826 # 8001c698 <log+0x30>
    struct buf *to = bread(log.dev, log.start+tail+1); // log block
    800049da:	00018a17          	auipc	s4,0x18
    800049de:	c8ea0a13          	addi	s4,s4,-882 # 8001c668 <log>
    800049e2:	018a2583          	lw	a1,24(s4)
    800049e6:	012585bb          	addw	a1,a1,s2
    800049ea:	2585                	addiw	a1,a1,1
    800049ec:	028a2503          	lw	a0,40(s4)
    800049f0:	ffffe097          	auipc	ra,0xffffe
    800049f4:	3ea080e7          	jalr	1002(ra) # 80002dda <bread>
    800049f8:	84aa                	mv	s1,a0
    struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block
    800049fa:	000aa583          	lw	a1,0(s5)
    800049fe:	028a2503          	lw	a0,40(s4)
    80004a02:	ffffe097          	auipc	ra,0xffffe
    80004a06:	3d8080e7          	jalr	984(ra) # 80002dda <bread>
    80004a0a:	89aa                	mv	s3,a0
    memmove(to->data, from->data, BSIZE);
    80004a0c:	40000613          	li	a2,1024
    80004a10:	05850593          	addi	a1,a0,88
    80004a14:	05848513          	addi	a0,s1,88
    80004a18:	ffffc097          	auipc	ra,0xffffc
    80004a1c:	302080e7          	jalr	770(ra) # 80000d1a <memmove>
    bwrite(to);  // write the log
    80004a20:	8526                	mv	a0,s1
    80004a22:	ffffe097          	auipc	ra,0xffffe
    80004a26:	4aa080e7          	jalr	1194(ra) # 80002ecc <bwrite>
    brelse(from);
    80004a2a:	854e                	mv	a0,s3
    80004a2c:	ffffe097          	auipc	ra,0xffffe
    80004a30:	4de080e7          	jalr	1246(ra) # 80002f0a <brelse>
    brelse(to);
    80004a34:	8526                	mv	a0,s1
    80004a36:	ffffe097          	auipc	ra,0xffffe
    80004a3a:	4d4080e7          	jalr	1236(ra) # 80002f0a <brelse>
  for (tail = 0; tail < log.lh.n; tail++) {
    80004a3e:	2905                	addiw	s2,s2,1
    80004a40:	0a91                	addi	s5,s5,4
    80004a42:	02ca2783          	lw	a5,44(s4)
    80004a46:	f8f94ee3          	blt	s2,a5,800049e2 <end_op+0xcc>
    write_log();     // Write modified blocks from cache to log
    write_head();    // Write header to disk -- the real commit
    80004a4a:	00000097          	auipc	ra,0x0
    80004a4e:	c68080e7          	jalr	-920(ra) # 800046b2 <write_head>
    install_trans(0); // Now install writes to home locations
    80004a52:	4501                	li	a0,0
    80004a54:	00000097          	auipc	ra,0x0
    80004a58:	cda080e7          	jalr	-806(ra) # 8000472e <install_trans>
    log.lh.n = 0;
    80004a5c:	00018797          	auipc	a5,0x18
    80004a60:	c207ac23          	sw	zero,-968(a5) # 8001c694 <log+0x2c>
    write_head();    // Erase the transaction from the log
    80004a64:	00000097          	auipc	ra,0x0
    80004a68:	c4e080e7          	jalr	-946(ra) # 800046b2 <write_head>
    80004a6c:	bdf5                	j	80004968 <end_op+0x52>

0000000080004a6e <log_write>:
//   modify bp->data[]
//   log_write(bp)
//   brelse(bp)
void
log_write(struct buf *b)
{
    80004a6e:	1101                	addi	sp,sp,-32
    80004a70:	ec06                	sd	ra,24(sp)
    80004a72:	e822                	sd	s0,16(sp)
    80004a74:	e426                	sd	s1,8(sp)
    80004a76:	e04a                	sd	s2,0(sp)
    80004a78:	1000                	addi	s0,sp,32
  int i;

  if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1)
    80004a7a:	00018717          	auipc	a4,0x18
    80004a7e:	c1a72703          	lw	a4,-998(a4) # 8001c694 <log+0x2c>
    80004a82:	47f5                	li	a5,29
    80004a84:	08e7c063          	blt	a5,a4,80004b04 <log_write+0x96>
    80004a88:	84aa                	mv	s1,a0
    80004a8a:	00018797          	auipc	a5,0x18
    80004a8e:	bfa7a783          	lw	a5,-1030(a5) # 8001c684 <log+0x1c>
    80004a92:	37fd                	addiw	a5,a5,-1
    80004a94:	06f75863          	bge	a4,a5,80004b04 <log_write+0x96>
    panic("too big a transaction");
  if (log.outstanding < 1)
    80004a98:	00018797          	auipc	a5,0x18
    80004a9c:	bf07a783          	lw	a5,-1040(a5) # 8001c688 <log+0x20>
    80004aa0:	06f05a63          	blez	a5,80004b14 <log_write+0xa6>
    panic("log_write outside of trans");

  acquire(&log.lock);
    80004aa4:	00018917          	auipc	s2,0x18
    80004aa8:	bc490913          	addi	s2,s2,-1084 # 8001c668 <log>
    80004aac:	854a                	mv	a0,s2
    80004aae:	ffffc097          	auipc	ra,0xffffc
    80004ab2:	114080e7          	jalr	276(ra) # 80000bc2 <acquire>
  for (i = 0; i < log.lh.n; i++) {
    80004ab6:	02c92603          	lw	a2,44(s2)
    80004aba:	06c05563          	blez	a2,80004b24 <log_write+0xb6>
    if (log.lh.block[i] == b->blockno)   // log absorbtion
    80004abe:	44cc                	lw	a1,12(s1)
    80004ac0:	00018717          	auipc	a4,0x18
    80004ac4:	bd870713          	addi	a4,a4,-1064 # 8001c698 <log+0x30>
  for (i = 0; i < log.lh.n; i++) {
    80004ac8:	4781                	li	a5,0
    if (log.lh.block[i] == b->blockno)   // log absorbtion
    80004aca:	4314                	lw	a3,0(a4)
    80004acc:	04b68d63          	beq	a3,a1,80004b26 <log_write+0xb8>
  for (i = 0; i < log.lh.n; i++) {
    80004ad0:	2785                	addiw	a5,a5,1
    80004ad2:	0711                	addi	a4,a4,4
    80004ad4:	fec79be3          	bne	a5,a2,80004aca <log_write+0x5c>
      break;
  }
  log.lh.block[i] = b->blockno;
    80004ad8:	0621                	addi	a2,a2,8
    80004ada:	060a                	slli	a2,a2,0x2
    80004adc:	00018797          	auipc	a5,0x18
    80004ae0:	b8c78793          	addi	a5,a5,-1140 # 8001c668 <log>
    80004ae4:	97b2                	add	a5,a5,a2
    80004ae6:	44d8                	lw	a4,12(s1)
    80004ae8:	cb98                	sw	a4,16(a5)
  if (i == log.lh.n) {  // Add new block to log?
    bpin(b);
    80004aea:	8526                	mv	a0,s1
    80004aec:	ffffe097          	auipc	ra,0xffffe
    80004af0:	4bc080e7          	jalr	1212(ra) # 80002fa8 <bpin>
    log.lh.n++;
    80004af4:	00018717          	auipc	a4,0x18
    80004af8:	b7470713          	addi	a4,a4,-1164 # 8001c668 <log>
    80004afc:	575c                	lw	a5,44(a4)
    80004afe:	2785                	addiw	a5,a5,1
    80004b00:	d75c                	sw	a5,44(a4)
    80004b02:	a835                	j	80004b3e <log_write+0xd0>
    panic("too big a transaction");
    80004b04:	00004517          	auipc	a0,0x4
    80004b08:	ae450513          	addi	a0,a0,-1308 # 800085e8 <syscalls+0x1c8>
    80004b0c:	ffffc097          	auipc	ra,0xffffc
    80004b10:	a20080e7          	jalr	-1504(ra) # 8000052c <panic>
    panic("log_write outside of trans");
    80004b14:	00004517          	auipc	a0,0x4
    80004b18:	aec50513          	addi	a0,a0,-1300 # 80008600 <syscalls+0x1e0>
    80004b1c:	ffffc097          	auipc	ra,0xffffc
    80004b20:	a10080e7          	jalr	-1520(ra) # 8000052c <panic>
  for (i = 0; i < log.lh.n; i++) {
    80004b24:	4781                	li	a5,0
  log.lh.block[i] = b->blockno;
    80004b26:	00878693          	addi	a3,a5,8
    80004b2a:	068a                	slli	a3,a3,0x2
    80004b2c:	00018717          	auipc	a4,0x18
    80004b30:	b3c70713          	addi	a4,a4,-1220 # 8001c668 <log>
    80004b34:	9736                	add	a4,a4,a3
    80004b36:	44d4                	lw	a3,12(s1)
    80004b38:	cb14                	sw	a3,16(a4)
  if (i == log.lh.n) {  // Add new block to log?
    80004b3a:	faf608e3          	beq	a2,a5,80004aea <log_write+0x7c>
  }
  release(&log.lock);
    80004b3e:	00018517          	auipc	a0,0x18
    80004b42:	b2a50513          	addi	a0,a0,-1238 # 8001c668 <log>
    80004b46:	ffffc097          	auipc	ra,0xffffc
    80004b4a:	130080e7          	jalr	304(ra) # 80000c76 <release>
}
    80004b4e:	60e2                	ld	ra,24(sp)
    80004b50:	6442                	ld	s0,16(sp)
    80004b52:	64a2                	ld	s1,8(sp)
    80004b54:	6902                	ld	s2,0(sp)
    80004b56:	6105                	addi	sp,sp,32
    80004b58:	8082                	ret

0000000080004b5a <initsleeplock>:
#include "proc.h"
#include "sleeplock.h"

void
initsleeplock(struct sleeplock *lk, char *name)
{
    80004b5a:	1101                	addi	sp,sp,-32
    80004b5c:	ec06                	sd	ra,24(sp)
    80004b5e:	e822                	sd	s0,16(sp)
    80004b60:	e426                	sd	s1,8(sp)
    80004b62:	e04a                	sd	s2,0(sp)
    80004b64:	1000                	addi	s0,sp,32
    80004b66:	84aa                	mv	s1,a0
    80004b68:	892e                	mv	s2,a1
  initlock(&lk->lk, "sleep lock");
    80004b6a:	00004597          	auipc	a1,0x4
    80004b6e:	ab658593          	addi	a1,a1,-1354 # 80008620 <syscalls+0x200>
    80004b72:	0521                	addi	a0,a0,8
    80004b74:	ffffc097          	auipc	ra,0xffffc
    80004b78:	fbe080e7          	jalr	-66(ra) # 80000b32 <initlock>
  lk->name = name;
    80004b7c:	0324b023          	sd	s2,32(s1)
  lk->locked = 0;
    80004b80:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    80004b84:	0204a423          	sw	zero,40(s1)
}
    80004b88:	60e2                	ld	ra,24(sp)
    80004b8a:	6442                	ld	s0,16(sp)
    80004b8c:	64a2                	ld	s1,8(sp)
    80004b8e:	6902                	ld	s2,0(sp)
    80004b90:	6105                	addi	sp,sp,32
    80004b92:	8082                	ret

0000000080004b94 <acquiresleep>:

void
acquiresleep(struct sleeplock *lk)
{
    80004b94:	1101                	addi	sp,sp,-32
    80004b96:	ec06                	sd	ra,24(sp)
    80004b98:	e822                	sd	s0,16(sp)
    80004b9a:	e426                	sd	s1,8(sp)
    80004b9c:	e04a                	sd	s2,0(sp)
    80004b9e:	1000                	addi	s0,sp,32
    80004ba0:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    80004ba2:	00850913          	addi	s2,a0,8
    80004ba6:	854a                	mv	a0,s2
    80004ba8:	ffffc097          	auipc	ra,0xffffc
    80004bac:	01a080e7          	jalr	26(ra) # 80000bc2 <acquire>
  while (lk->locked) {
    80004bb0:	409c                	lw	a5,0(s1)
    80004bb2:	cb89                	beqz	a5,80004bc4 <acquiresleep+0x30>
    sleep(lk, &lk->lk);
    80004bb4:	85ca                	mv	a1,s2
    80004bb6:	8526                	mv	a0,s1
    80004bb8:	ffffd097          	auipc	ra,0xffffd
    80004bbc:	60a080e7          	jalr	1546(ra) # 800021c2 <sleep>
  while (lk->locked) {
    80004bc0:	409c                	lw	a5,0(s1)
    80004bc2:	fbed                	bnez	a5,80004bb4 <acquiresleep+0x20>
  }
  lk->locked = 1;
    80004bc4:	4785                	li	a5,1
    80004bc6:	c09c                	sw	a5,0(s1)
  lk->pid = myproc()->pid;
    80004bc8:	ffffd097          	auipc	ra,0xffffd
    80004bcc:	de2080e7          	jalr	-542(ra) # 800019aa <myproc>
    80004bd0:	5d1c                	lw	a5,56(a0)
    80004bd2:	d49c                	sw	a5,40(s1)
  release(&lk->lk);
    80004bd4:	854a                	mv	a0,s2
    80004bd6:	ffffc097          	auipc	ra,0xffffc
    80004bda:	0a0080e7          	jalr	160(ra) # 80000c76 <release>
}
    80004bde:	60e2                	ld	ra,24(sp)
    80004be0:	6442                	ld	s0,16(sp)
    80004be2:	64a2                	ld	s1,8(sp)
    80004be4:	6902                	ld	s2,0(sp)
    80004be6:	6105                	addi	sp,sp,32
    80004be8:	8082                	ret

0000000080004bea <releasesleep>:

void
releasesleep(struct sleeplock *lk)
{
    80004bea:	1101                	addi	sp,sp,-32
    80004bec:	ec06                	sd	ra,24(sp)
    80004bee:	e822                	sd	s0,16(sp)
    80004bf0:	e426                	sd	s1,8(sp)
    80004bf2:	e04a                	sd	s2,0(sp)
    80004bf4:	1000                	addi	s0,sp,32
    80004bf6:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    80004bf8:	00850913          	addi	s2,a0,8
    80004bfc:	854a                	mv	a0,s2
    80004bfe:	ffffc097          	auipc	ra,0xffffc
    80004c02:	fc4080e7          	jalr	-60(ra) # 80000bc2 <acquire>
  lk->locked = 0;
    80004c06:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    80004c0a:	0204a423          	sw	zero,40(s1)
  wakeup(lk);
    80004c0e:	8526                	mv	a0,s1
    80004c10:	ffffd097          	auipc	ra,0xffffd
    80004c14:	732080e7          	jalr	1842(ra) # 80002342 <wakeup>
  release(&lk->lk);
    80004c18:	854a                	mv	a0,s2
    80004c1a:	ffffc097          	auipc	ra,0xffffc
    80004c1e:	05c080e7          	jalr	92(ra) # 80000c76 <release>
}
    80004c22:	60e2                	ld	ra,24(sp)
    80004c24:	6442                	ld	s0,16(sp)
    80004c26:	64a2                	ld	s1,8(sp)
    80004c28:	6902                	ld	s2,0(sp)
    80004c2a:	6105                	addi	sp,sp,32
    80004c2c:	8082                	ret

0000000080004c2e <holdingsleep>:

int
holdingsleep(struct sleeplock *lk)
{
    80004c2e:	7179                	addi	sp,sp,-48
    80004c30:	f406                	sd	ra,40(sp)
    80004c32:	f022                	sd	s0,32(sp)
    80004c34:	ec26                	sd	s1,24(sp)
    80004c36:	e84a                	sd	s2,16(sp)
    80004c38:	e44e                	sd	s3,8(sp)
    80004c3a:	1800                	addi	s0,sp,48
    80004c3c:	84aa                	mv	s1,a0
  int r;
  
  acquire(&lk->lk);
    80004c3e:	00850913          	addi	s2,a0,8
    80004c42:	854a                	mv	a0,s2
    80004c44:	ffffc097          	auipc	ra,0xffffc
    80004c48:	f7e080e7          	jalr	-130(ra) # 80000bc2 <acquire>
  r = lk->locked && (lk->pid == myproc()->pid);
    80004c4c:	409c                	lw	a5,0(s1)
    80004c4e:	ef99                	bnez	a5,80004c6c <holdingsleep+0x3e>
    80004c50:	4481                	li	s1,0
  release(&lk->lk);
    80004c52:	854a                	mv	a0,s2
    80004c54:	ffffc097          	auipc	ra,0xffffc
    80004c58:	022080e7          	jalr	34(ra) # 80000c76 <release>
  return r;
}
    80004c5c:	8526                	mv	a0,s1
    80004c5e:	70a2                	ld	ra,40(sp)
    80004c60:	7402                	ld	s0,32(sp)
    80004c62:	64e2                	ld	s1,24(sp)
    80004c64:	6942                	ld	s2,16(sp)
    80004c66:	69a2                	ld	s3,8(sp)
    80004c68:	6145                	addi	sp,sp,48
    80004c6a:	8082                	ret
  r = lk->locked && (lk->pid == myproc()->pid);
    80004c6c:	0284a983          	lw	s3,40(s1)
    80004c70:	ffffd097          	auipc	ra,0xffffd
    80004c74:	d3a080e7          	jalr	-710(ra) # 800019aa <myproc>
    80004c78:	5d04                	lw	s1,56(a0)
    80004c7a:	413484b3          	sub	s1,s1,s3
    80004c7e:	0014b493          	seqz	s1,s1
    80004c82:	bfc1                	j	80004c52 <holdingsleep+0x24>

0000000080004c84 <fileinit>:
  struct file file[NFILE];
} ftable;

void
fileinit(void)
{
    80004c84:	1141                	addi	sp,sp,-16
    80004c86:	e406                	sd	ra,8(sp)
    80004c88:	e022                	sd	s0,0(sp)
    80004c8a:	0800                	addi	s0,sp,16
  initlock(&ftable.lock, "ftable");
    80004c8c:	00004597          	auipc	a1,0x4
    80004c90:	9a458593          	addi	a1,a1,-1628 # 80008630 <syscalls+0x210>
    80004c94:	00018517          	auipc	a0,0x18
    80004c98:	b1c50513          	addi	a0,a0,-1252 # 8001c7b0 <ftable>
    80004c9c:	ffffc097          	auipc	ra,0xffffc
    80004ca0:	e96080e7          	jalr	-362(ra) # 80000b32 <initlock>
}
    80004ca4:	60a2                	ld	ra,8(sp)
    80004ca6:	6402                	ld	s0,0(sp)
    80004ca8:	0141                	addi	sp,sp,16
    80004caa:	8082                	ret

0000000080004cac <filealloc>:

// Allocate a file structure.
struct file*
filealloc(void)
{
    80004cac:	1101                	addi	sp,sp,-32
    80004cae:	ec06                	sd	ra,24(sp)
    80004cb0:	e822                	sd	s0,16(sp)
    80004cb2:	e426                	sd	s1,8(sp)
    80004cb4:	1000                	addi	s0,sp,32
  struct file *f;

  acquire(&ftable.lock);
    80004cb6:	00018517          	auipc	a0,0x18
    80004cba:	afa50513          	addi	a0,a0,-1286 # 8001c7b0 <ftable>
    80004cbe:	ffffc097          	auipc	ra,0xffffc
    80004cc2:	f04080e7          	jalr	-252(ra) # 80000bc2 <acquire>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004cc6:	00018497          	auipc	s1,0x18
    80004cca:	b0248493          	addi	s1,s1,-1278 # 8001c7c8 <ftable+0x18>
    80004cce:	00019717          	auipc	a4,0x19
    80004cd2:	a9a70713          	addi	a4,a4,-1382 # 8001d768 <ftable+0xfb8>
    if(f->ref == 0){
    80004cd6:	40dc                	lw	a5,4(s1)
    80004cd8:	cf99                	beqz	a5,80004cf6 <filealloc+0x4a>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004cda:	02848493          	addi	s1,s1,40
    80004cde:	fee49ce3          	bne	s1,a4,80004cd6 <filealloc+0x2a>
      f->ref = 1;
      release(&ftable.lock);
      return f;
    }
  }
  release(&ftable.lock);
    80004ce2:	00018517          	auipc	a0,0x18
    80004ce6:	ace50513          	addi	a0,a0,-1330 # 8001c7b0 <ftable>
    80004cea:	ffffc097          	auipc	ra,0xffffc
    80004cee:	f8c080e7          	jalr	-116(ra) # 80000c76 <release>
  return 0;
    80004cf2:	4481                	li	s1,0
    80004cf4:	a819                	j	80004d0a <filealloc+0x5e>
      f->ref = 1;
    80004cf6:	4785                	li	a5,1
    80004cf8:	c0dc                	sw	a5,4(s1)
      release(&ftable.lock);
    80004cfa:	00018517          	auipc	a0,0x18
    80004cfe:	ab650513          	addi	a0,a0,-1354 # 8001c7b0 <ftable>
    80004d02:	ffffc097          	auipc	ra,0xffffc
    80004d06:	f74080e7          	jalr	-140(ra) # 80000c76 <release>
}
    80004d0a:	8526                	mv	a0,s1
    80004d0c:	60e2                	ld	ra,24(sp)
    80004d0e:	6442                	ld	s0,16(sp)
    80004d10:	64a2                	ld	s1,8(sp)
    80004d12:	6105                	addi	sp,sp,32
    80004d14:	8082                	ret

0000000080004d16 <filedup>:

// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
    80004d16:	1101                	addi	sp,sp,-32
    80004d18:	ec06                	sd	ra,24(sp)
    80004d1a:	e822                	sd	s0,16(sp)
    80004d1c:	e426                	sd	s1,8(sp)
    80004d1e:	1000                	addi	s0,sp,32
    80004d20:	84aa                	mv	s1,a0
  acquire(&ftable.lock);
    80004d22:	00018517          	auipc	a0,0x18
    80004d26:	a8e50513          	addi	a0,a0,-1394 # 8001c7b0 <ftable>
    80004d2a:	ffffc097          	auipc	ra,0xffffc
    80004d2e:	e98080e7          	jalr	-360(ra) # 80000bc2 <acquire>
  if(f->ref < 1)
    80004d32:	40dc                	lw	a5,4(s1)
    80004d34:	02f05263          	blez	a5,80004d58 <filedup+0x42>
    panic("filedup");
  f->ref++;
    80004d38:	2785                	addiw	a5,a5,1
    80004d3a:	c0dc                	sw	a5,4(s1)
  release(&ftable.lock);
    80004d3c:	00018517          	auipc	a0,0x18
    80004d40:	a7450513          	addi	a0,a0,-1420 # 8001c7b0 <ftable>
    80004d44:	ffffc097          	auipc	ra,0xffffc
    80004d48:	f32080e7          	jalr	-206(ra) # 80000c76 <release>
  return f;
}
    80004d4c:	8526                	mv	a0,s1
    80004d4e:	60e2                	ld	ra,24(sp)
    80004d50:	6442                	ld	s0,16(sp)
    80004d52:	64a2                	ld	s1,8(sp)
    80004d54:	6105                	addi	sp,sp,32
    80004d56:	8082                	ret
    panic("filedup");
    80004d58:	00004517          	auipc	a0,0x4
    80004d5c:	8e050513          	addi	a0,a0,-1824 # 80008638 <syscalls+0x218>
    80004d60:	ffffb097          	auipc	ra,0xffffb
    80004d64:	7cc080e7          	jalr	1996(ra) # 8000052c <panic>

0000000080004d68 <fileclose>:

// Close file f.  (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
    80004d68:	7139                	addi	sp,sp,-64
    80004d6a:	fc06                	sd	ra,56(sp)
    80004d6c:	f822                	sd	s0,48(sp)
    80004d6e:	f426                	sd	s1,40(sp)
    80004d70:	f04a                	sd	s2,32(sp)
    80004d72:	ec4e                	sd	s3,24(sp)
    80004d74:	e852                	sd	s4,16(sp)
    80004d76:	e456                	sd	s5,8(sp)
    80004d78:	0080                	addi	s0,sp,64
    80004d7a:	84aa                	mv	s1,a0
  struct file ff;

  acquire(&ftable.lock);
    80004d7c:	00018517          	auipc	a0,0x18
    80004d80:	a3450513          	addi	a0,a0,-1484 # 8001c7b0 <ftable>
    80004d84:	ffffc097          	auipc	ra,0xffffc
    80004d88:	e3e080e7          	jalr	-450(ra) # 80000bc2 <acquire>
  if(f->ref < 1)
    80004d8c:	40dc                	lw	a5,4(s1)
    80004d8e:	06f05163          	blez	a5,80004df0 <fileclose+0x88>
    panic("fileclose");
  if(--f->ref > 0){
    80004d92:	37fd                	addiw	a5,a5,-1
    80004d94:	0007871b          	sext.w	a4,a5
    80004d98:	c0dc                	sw	a5,4(s1)
    80004d9a:	06e04363          	bgtz	a4,80004e00 <fileclose+0x98>
    release(&ftable.lock);
    return;
  }
  ff = *f;
    80004d9e:	0004a903          	lw	s2,0(s1)
    80004da2:	0094ca83          	lbu	s5,9(s1)
    80004da6:	0104ba03          	ld	s4,16(s1)
    80004daa:	0184b983          	ld	s3,24(s1)
  f->ref = 0;
    80004dae:	0004a223          	sw	zero,4(s1)
  f->type = FD_NONE;
    80004db2:	0004a023          	sw	zero,0(s1)
  release(&ftable.lock);
    80004db6:	00018517          	auipc	a0,0x18
    80004dba:	9fa50513          	addi	a0,a0,-1542 # 8001c7b0 <ftable>
    80004dbe:	ffffc097          	auipc	ra,0xffffc
    80004dc2:	eb8080e7          	jalr	-328(ra) # 80000c76 <release>

  if(ff.type == FD_PIPE){
    80004dc6:	4785                	li	a5,1
    80004dc8:	04f90d63          	beq	s2,a5,80004e22 <fileclose+0xba>
    pipeclose(ff.pipe, ff.writable);
  } else if(ff.type == FD_INODE || ff.type == FD_DEVICE){
    80004dcc:	3979                	addiw	s2,s2,-2
    80004dce:	4785                	li	a5,1
    80004dd0:	0527e063          	bltu	a5,s2,80004e10 <fileclose+0xa8>
    begin_op();
    80004dd4:	00000097          	auipc	ra,0x0
    80004dd8:	ac4080e7          	jalr	-1340(ra) # 80004898 <begin_op>
    iput(ff.ip);
    80004ddc:	854e                	mv	a0,s3
    80004dde:	fffff097          	auipc	ra,0xfffff
    80004de2:	b26080e7          	jalr	-1242(ra) # 80003904 <iput>
    end_op();
    80004de6:	00000097          	auipc	ra,0x0
    80004dea:	b30080e7          	jalr	-1232(ra) # 80004916 <end_op>
    80004dee:	a00d                	j	80004e10 <fileclose+0xa8>
    panic("fileclose");
    80004df0:	00004517          	auipc	a0,0x4
    80004df4:	85050513          	addi	a0,a0,-1968 # 80008640 <syscalls+0x220>
    80004df8:	ffffb097          	auipc	ra,0xffffb
    80004dfc:	734080e7          	jalr	1844(ra) # 8000052c <panic>
    release(&ftable.lock);
    80004e00:	00018517          	auipc	a0,0x18
    80004e04:	9b050513          	addi	a0,a0,-1616 # 8001c7b0 <ftable>
    80004e08:	ffffc097          	auipc	ra,0xffffc
    80004e0c:	e6e080e7          	jalr	-402(ra) # 80000c76 <release>
  }
}
    80004e10:	70e2                	ld	ra,56(sp)
    80004e12:	7442                	ld	s0,48(sp)
    80004e14:	74a2                	ld	s1,40(sp)
    80004e16:	7902                	ld	s2,32(sp)
    80004e18:	69e2                	ld	s3,24(sp)
    80004e1a:	6a42                	ld	s4,16(sp)
    80004e1c:	6aa2                	ld	s5,8(sp)
    80004e1e:	6121                	addi	sp,sp,64
    80004e20:	8082                	ret
    pipeclose(ff.pipe, ff.writable);
    80004e22:	85d6                	mv	a1,s5
    80004e24:	8552                	mv	a0,s4
    80004e26:	00000097          	auipc	ra,0x0
    80004e2a:	34c080e7          	jalr	844(ra) # 80005172 <pipeclose>
    80004e2e:	b7cd                	j	80004e10 <fileclose+0xa8>

0000000080004e30 <filestat>:

// Get metadata about file f.
// addr is a user virtual address, pointing to a struct stat.
int
filestat(struct file *f, uint64 addr)
{
    80004e30:	715d                	addi	sp,sp,-80
    80004e32:	e486                	sd	ra,72(sp)
    80004e34:	e0a2                	sd	s0,64(sp)
    80004e36:	fc26                	sd	s1,56(sp)
    80004e38:	f84a                	sd	s2,48(sp)
    80004e3a:	f44e                	sd	s3,40(sp)
    80004e3c:	0880                	addi	s0,sp,80
    80004e3e:	84aa                	mv	s1,a0
    80004e40:	89ae                	mv	s3,a1
  struct proc *p = myproc();
    80004e42:	ffffd097          	auipc	ra,0xffffd
    80004e46:	b68080e7          	jalr	-1176(ra) # 800019aa <myproc>
  struct stat st;
  
  if(f->type == FD_INODE || f->type == FD_DEVICE){
    80004e4a:	409c                	lw	a5,0(s1)
    80004e4c:	37f9                	addiw	a5,a5,-2
    80004e4e:	4705                	li	a4,1
    80004e50:	04f76763          	bltu	a4,a5,80004e9e <filestat+0x6e>
    80004e54:	892a                	mv	s2,a0
    ilock(f->ip);
    80004e56:	6c88                	ld	a0,24(s1)
    80004e58:	fffff097          	auipc	ra,0xfffff
    80004e5c:	84c080e7          	jalr	-1972(ra) # 800036a4 <ilock>
    stati(f->ip, &st);
    80004e60:	fb840593          	addi	a1,s0,-72
    80004e64:	6c88                	ld	a0,24(s1)
    80004e66:	fffff097          	auipc	ra,0xfffff
    80004e6a:	b6e080e7          	jalr	-1170(ra) # 800039d4 <stati>
    iunlock(f->ip);
    80004e6e:	6c88                	ld	a0,24(s1)
    80004e70:	fffff097          	auipc	ra,0xfffff
    80004e74:	8f6080e7          	jalr	-1802(ra) # 80003766 <iunlock>
    if(copyout(p->pagetable, addr, (char *)&st, sizeof(st)) < 0)
    80004e78:	46e1                	li	a3,24
    80004e7a:	fb840613          	addi	a2,s0,-72
    80004e7e:	85ce                	mv	a1,s3
    80004e80:	05093503          	ld	a0,80(s2)
    80004e84:	ffffc097          	auipc	ra,0xffffc
    80004e88:	7be080e7          	jalr	1982(ra) # 80001642 <copyout>
    80004e8c:	41f5551b          	sraiw	a0,a0,0x1f
      return -1;
    return 0;
  }
  return -1;
}
    80004e90:	60a6                	ld	ra,72(sp)
    80004e92:	6406                	ld	s0,64(sp)
    80004e94:	74e2                	ld	s1,56(sp)
    80004e96:	7942                	ld	s2,48(sp)
    80004e98:	79a2                	ld	s3,40(sp)
    80004e9a:	6161                	addi	sp,sp,80
    80004e9c:	8082                	ret
  return -1;
    80004e9e:	557d                	li	a0,-1
    80004ea0:	bfc5                	j	80004e90 <filestat+0x60>

0000000080004ea2 <fileread>:

// Read from file f.
// addr is a user virtual address.
int
fileread(struct file *f, uint64 addr, int n)
{
    80004ea2:	7179                	addi	sp,sp,-48
    80004ea4:	f406                	sd	ra,40(sp)
    80004ea6:	f022                	sd	s0,32(sp)
    80004ea8:	ec26                	sd	s1,24(sp)
    80004eaa:	e84a                	sd	s2,16(sp)
    80004eac:	e44e                	sd	s3,8(sp)
    80004eae:	1800                	addi	s0,sp,48
  int r = 0;

  if(f->readable == 0)
    80004eb0:	00854783          	lbu	a5,8(a0)
    80004eb4:	c3d5                	beqz	a5,80004f58 <fileread+0xb6>
    80004eb6:	84aa                	mv	s1,a0
    80004eb8:	89ae                	mv	s3,a1
    80004eba:	8932                	mv	s2,a2
    return -1;

  if(f->type == FD_PIPE){
    80004ebc:	411c                	lw	a5,0(a0)
    80004ebe:	4705                	li	a4,1
    80004ec0:	04e78963          	beq	a5,a4,80004f12 <fileread+0x70>
    r = piperead(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    80004ec4:	470d                	li	a4,3
    80004ec6:	04e78d63          	beq	a5,a4,80004f20 <fileread+0x7e>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
      return -1;
    r = devsw[f->major].read(1, addr, n);
  } else if(f->type == FD_INODE){
    80004eca:	4709                	li	a4,2
    80004ecc:	06e79e63          	bne	a5,a4,80004f48 <fileread+0xa6>
    ilock(f->ip);
    80004ed0:	6d08                	ld	a0,24(a0)
    80004ed2:	ffffe097          	auipc	ra,0xffffe
    80004ed6:	7d2080e7          	jalr	2002(ra) # 800036a4 <ilock>
    if((r = readi(f->ip, 1, addr, f->off, n)) > 0)
    80004eda:	874a                	mv	a4,s2
    80004edc:	5094                	lw	a3,32(s1)
    80004ede:	864e                	mv	a2,s3
    80004ee0:	4585                	li	a1,1
    80004ee2:	6c88                	ld	a0,24(s1)
    80004ee4:	fffff097          	auipc	ra,0xfffff
    80004ee8:	b1a080e7          	jalr	-1254(ra) # 800039fe <readi>
    80004eec:	892a                	mv	s2,a0
    80004eee:	00a05563          	blez	a0,80004ef8 <fileread+0x56>
      f->off += r;
    80004ef2:	509c                	lw	a5,32(s1)
    80004ef4:	9fa9                	addw	a5,a5,a0
    80004ef6:	d09c                	sw	a5,32(s1)
    iunlock(f->ip);
    80004ef8:	6c88                	ld	a0,24(s1)
    80004efa:	fffff097          	auipc	ra,0xfffff
    80004efe:	86c080e7          	jalr	-1940(ra) # 80003766 <iunlock>
  } else {
    panic("fileread");
  }

  return r;
}
    80004f02:	854a                	mv	a0,s2
    80004f04:	70a2                	ld	ra,40(sp)
    80004f06:	7402                	ld	s0,32(sp)
    80004f08:	64e2                	ld	s1,24(sp)
    80004f0a:	6942                	ld	s2,16(sp)
    80004f0c:	69a2                	ld	s3,8(sp)
    80004f0e:	6145                	addi	sp,sp,48
    80004f10:	8082                	ret
    r = piperead(f->pipe, addr, n);
    80004f12:	6908                	ld	a0,16(a0)
    80004f14:	00000097          	auipc	ra,0x0
    80004f18:	3c0080e7          	jalr	960(ra) # 800052d4 <piperead>
    80004f1c:	892a                	mv	s2,a0
    80004f1e:	b7d5                	j	80004f02 <fileread+0x60>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
    80004f20:	02451783          	lh	a5,36(a0)
    80004f24:	03079693          	slli	a3,a5,0x30
    80004f28:	92c1                	srli	a3,a3,0x30
    80004f2a:	4725                	li	a4,9
    80004f2c:	02d76863          	bltu	a4,a3,80004f5c <fileread+0xba>
    80004f30:	0792                	slli	a5,a5,0x4
    80004f32:	00017717          	auipc	a4,0x17
    80004f36:	7de70713          	addi	a4,a4,2014 # 8001c710 <devsw>
    80004f3a:	97ba                	add	a5,a5,a4
    80004f3c:	639c                	ld	a5,0(a5)
    80004f3e:	c38d                	beqz	a5,80004f60 <fileread+0xbe>
    r = devsw[f->major].read(1, addr, n);
    80004f40:	4505                	li	a0,1
    80004f42:	9782                	jalr	a5
    80004f44:	892a                	mv	s2,a0
    80004f46:	bf75                	j	80004f02 <fileread+0x60>
    panic("fileread");
    80004f48:	00003517          	auipc	a0,0x3
    80004f4c:	70850513          	addi	a0,a0,1800 # 80008650 <syscalls+0x230>
    80004f50:	ffffb097          	auipc	ra,0xffffb
    80004f54:	5dc080e7          	jalr	1500(ra) # 8000052c <panic>
    return -1;
    80004f58:	597d                	li	s2,-1
    80004f5a:	b765                	j	80004f02 <fileread+0x60>
      return -1;
    80004f5c:	597d                	li	s2,-1
    80004f5e:	b755                	j	80004f02 <fileread+0x60>
    80004f60:	597d                	li	s2,-1
    80004f62:	b745                	j	80004f02 <fileread+0x60>

0000000080004f64 <filewrite>:

// Write to file f.
// addr is a user virtual address.
int
filewrite(struct file *f, uint64 addr, int n)
{
    80004f64:	715d                	addi	sp,sp,-80
    80004f66:	e486                	sd	ra,72(sp)
    80004f68:	e0a2                	sd	s0,64(sp)
    80004f6a:	fc26                	sd	s1,56(sp)
    80004f6c:	f84a                	sd	s2,48(sp)
    80004f6e:	f44e                	sd	s3,40(sp)
    80004f70:	f052                	sd	s4,32(sp)
    80004f72:	ec56                	sd	s5,24(sp)
    80004f74:	e85a                	sd	s6,16(sp)
    80004f76:	e45e                	sd	s7,8(sp)
    80004f78:	e062                	sd	s8,0(sp)
    80004f7a:	0880                	addi	s0,sp,80
  int r, ret = 0;

  if(f->writable == 0)
    80004f7c:	00954783          	lbu	a5,9(a0)
    80004f80:	10078663          	beqz	a5,8000508c <filewrite+0x128>
    80004f84:	892a                	mv	s2,a0
    80004f86:	8b2e                	mv	s6,a1
    80004f88:	8a32                	mv	s4,a2
    return -1;

  if(f->type == FD_PIPE){
    80004f8a:	411c                	lw	a5,0(a0)
    80004f8c:	4705                	li	a4,1
    80004f8e:	02e78263          	beq	a5,a4,80004fb2 <filewrite+0x4e>
    ret = pipewrite(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    80004f92:	470d                	li	a4,3
    80004f94:	02e78663          	beq	a5,a4,80004fc0 <filewrite+0x5c>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
      return -1;
    ret = devsw[f->major].write(1, addr, n);
  } else if(f->type == FD_INODE){
    80004f98:	4709                	li	a4,2
    80004f9a:	0ee79163          	bne	a5,a4,8000507c <filewrite+0x118>
    // and 2 blocks of slop for non-aligned writes.
    // this really belongs lower down, since writei()
    // might be writing a device like the console.
    int max = ((MAXOPBLOCKS-1-1-2) / 2) * BSIZE;
    int i = 0;
    while(i < n){
    80004f9e:	0ac05d63          	blez	a2,80005058 <filewrite+0xf4>
    int i = 0;
    80004fa2:	4981                	li	s3,0
    80004fa4:	6b85                	lui	s7,0x1
    80004fa6:	c00b8b93          	addi	s7,s7,-1024 # c00 <_entry-0x7ffff400>
    80004faa:	6c05                	lui	s8,0x1
    80004fac:	c00c0c1b          	addiw	s8,s8,-1024 # c00 <_entry-0x7ffff400>
    80004fb0:	a861                	j	80005048 <filewrite+0xe4>
    ret = pipewrite(f->pipe, addr, n);
    80004fb2:	6908                	ld	a0,16(a0)
    80004fb4:	00000097          	auipc	ra,0x0
    80004fb8:	22e080e7          	jalr	558(ra) # 800051e2 <pipewrite>
    80004fbc:	8a2a                	mv	s4,a0
    80004fbe:	a045                	j	8000505e <filewrite+0xfa>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
    80004fc0:	02451783          	lh	a5,36(a0)
    80004fc4:	03079693          	slli	a3,a5,0x30
    80004fc8:	92c1                	srli	a3,a3,0x30
    80004fca:	4725                	li	a4,9
    80004fcc:	0cd76263          	bltu	a4,a3,80005090 <filewrite+0x12c>
    80004fd0:	0792                	slli	a5,a5,0x4
    80004fd2:	00017717          	auipc	a4,0x17
    80004fd6:	73e70713          	addi	a4,a4,1854 # 8001c710 <devsw>
    80004fda:	97ba                	add	a5,a5,a4
    80004fdc:	679c                	ld	a5,8(a5)
    80004fde:	cbdd                	beqz	a5,80005094 <filewrite+0x130>
    ret = devsw[f->major].write(1, addr, n);
    80004fe0:	4505                	li	a0,1
    80004fe2:	9782                	jalr	a5
    80004fe4:	8a2a                	mv	s4,a0
    80004fe6:	a8a5                	j	8000505e <filewrite+0xfa>
    80004fe8:	00048a9b          	sext.w	s5,s1
      int n1 = n - i;
      if(n1 > max)
        n1 = max;

      begin_op();
    80004fec:	00000097          	auipc	ra,0x0
    80004ff0:	8ac080e7          	jalr	-1876(ra) # 80004898 <begin_op>
      ilock(f->ip);
    80004ff4:	01893503          	ld	a0,24(s2)
    80004ff8:	ffffe097          	auipc	ra,0xffffe
    80004ffc:	6ac080e7          	jalr	1708(ra) # 800036a4 <ilock>
      if ((r = writei(f->ip, 1, addr + i, f->off, n1)) > 0)
    80005000:	8756                	mv	a4,s5
    80005002:	02092683          	lw	a3,32(s2)
    80005006:	01698633          	add	a2,s3,s6
    8000500a:	4585                	li	a1,1
    8000500c:	01893503          	ld	a0,24(s2)
    80005010:	fffff097          	auipc	ra,0xfffff
    80005014:	ae6080e7          	jalr	-1306(ra) # 80003af6 <writei>
    80005018:	84aa                	mv	s1,a0
    8000501a:	00a05763          	blez	a0,80005028 <filewrite+0xc4>
        f->off += r;
    8000501e:	02092783          	lw	a5,32(s2)
    80005022:	9fa9                	addw	a5,a5,a0
    80005024:	02f92023          	sw	a5,32(s2)
      iunlock(f->ip);
    80005028:	01893503          	ld	a0,24(s2)
    8000502c:	ffffe097          	auipc	ra,0xffffe
    80005030:	73a080e7          	jalr	1850(ra) # 80003766 <iunlock>
      end_op();
    80005034:	00000097          	auipc	ra,0x0
    80005038:	8e2080e7          	jalr	-1822(ra) # 80004916 <end_op>

      if(r != n1){
    8000503c:	009a9f63          	bne	s5,s1,8000505a <filewrite+0xf6>
        // error from writei
        break;
      }
      i += r;
    80005040:	013489bb          	addw	s3,s1,s3
    while(i < n){
    80005044:	0149db63          	bge	s3,s4,8000505a <filewrite+0xf6>
      int n1 = n - i;
    80005048:	413a04bb          	subw	s1,s4,s3
    8000504c:	0004879b          	sext.w	a5,s1
    80005050:	f8fbdce3          	bge	s7,a5,80004fe8 <filewrite+0x84>
    80005054:	84e2                	mv	s1,s8
    80005056:	bf49                	j	80004fe8 <filewrite+0x84>
    int i = 0;
    80005058:	4981                	li	s3,0
    }
    ret = (i == n ? n : -1);
    8000505a:	013a1f63          	bne	s4,s3,80005078 <filewrite+0x114>
  } else {
    panic("filewrite");
  }

  return ret;
}
    8000505e:	8552                	mv	a0,s4
    80005060:	60a6                	ld	ra,72(sp)
    80005062:	6406                	ld	s0,64(sp)
    80005064:	74e2                	ld	s1,56(sp)
    80005066:	7942                	ld	s2,48(sp)
    80005068:	79a2                	ld	s3,40(sp)
    8000506a:	7a02                	ld	s4,32(sp)
    8000506c:	6ae2                	ld	s5,24(sp)
    8000506e:	6b42                	ld	s6,16(sp)
    80005070:	6ba2                	ld	s7,8(sp)
    80005072:	6c02                	ld	s8,0(sp)
    80005074:	6161                	addi	sp,sp,80
    80005076:	8082                	ret
    ret = (i == n ? n : -1);
    80005078:	5a7d                	li	s4,-1
    8000507a:	b7d5                	j	8000505e <filewrite+0xfa>
    panic("filewrite");
    8000507c:	00003517          	auipc	a0,0x3
    80005080:	5e450513          	addi	a0,a0,1508 # 80008660 <syscalls+0x240>
    80005084:	ffffb097          	auipc	ra,0xffffb
    80005088:	4a8080e7          	jalr	1192(ra) # 8000052c <panic>
    return -1;
    8000508c:	5a7d                	li	s4,-1
    8000508e:	bfc1                	j	8000505e <filewrite+0xfa>
      return -1;
    80005090:	5a7d                	li	s4,-1
    80005092:	b7f1                	j	8000505e <filewrite+0xfa>
    80005094:	5a7d                	li	s4,-1
    80005096:	b7e1                	j	8000505e <filewrite+0xfa>

0000000080005098 <pipealloc>:
  int writeopen;  // write fd is still open
};

int
pipealloc(struct file **f0, struct file **f1)
{
    80005098:	7179                	addi	sp,sp,-48
    8000509a:	f406                	sd	ra,40(sp)
    8000509c:	f022                	sd	s0,32(sp)
    8000509e:	ec26                	sd	s1,24(sp)
    800050a0:	e84a                	sd	s2,16(sp)
    800050a2:	e44e                	sd	s3,8(sp)
    800050a4:	e052                	sd	s4,0(sp)
    800050a6:	1800                	addi	s0,sp,48
    800050a8:	84aa                	mv	s1,a0
    800050aa:	8a2e                	mv	s4,a1
  struct pipe *pi;

  pi = 0;
  *f0 = *f1 = 0;
    800050ac:	0005b023          	sd	zero,0(a1)
    800050b0:	00053023          	sd	zero,0(a0)
  if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
    800050b4:	00000097          	auipc	ra,0x0
    800050b8:	bf8080e7          	jalr	-1032(ra) # 80004cac <filealloc>
    800050bc:	e088                	sd	a0,0(s1)
    800050be:	c551                	beqz	a0,8000514a <pipealloc+0xb2>
    800050c0:	00000097          	auipc	ra,0x0
    800050c4:	bec080e7          	jalr	-1044(ra) # 80004cac <filealloc>
    800050c8:	00aa3023          	sd	a0,0(s4)
    800050cc:	c92d                	beqz	a0,8000513e <pipealloc+0xa6>
    goto bad;
  if((pi = (struct pipe*)kalloc()) == 0)
    800050ce:	ffffc097          	auipc	ra,0xffffc
    800050d2:	a04080e7          	jalr	-1532(ra) # 80000ad2 <kalloc>
    800050d6:	892a                	mv	s2,a0
    800050d8:	c125                	beqz	a0,80005138 <pipealloc+0xa0>
    goto bad;
  pi->readopen = 1;
    800050da:	4985                	li	s3,1
    800050dc:	23352023          	sw	s3,544(a0)
  pi->writeopen = 1;
    800050e0:	23352223          	sw	s3,548(a0)
  pi->nwrite = 0;
    800050e4:	20052e23          	sw	zero,540(a0)
  pi->nread = 0;
    800050e8:	20052c23          	sw	zero,536(a0)
  initlock(&pi->lock, "pipe");
    800050ec:	00003597          	auipc	a1,0x3
    800050f0:	58458593          	addi	a1,a1,1412 # 80008670 <syscalls+0x250>
    800050f4:	ffffc097          	auipc	ra,0xffffc
    800050f8:	a3e080e7          	jalr	-1474(ra) # 80000b32 <initlock>
  (*f0)->type = FD_PIPE;
    800050fc:	609c                	ld	a5,0(s1)
    800050fe:	0137a023          	sw	s3,0(a5)
  (*f0)->readable = 1;
    80005102:	609c                	ld	a5,0(s1)
    80005104:	01378423          	sb	s3,8(a5)
  (*f0)->writable = 0;
    80005108:	609c                	ld	a5,0(s1)
    8000510a:	000784a3          	sb	zero,9(a5)
  (*f0)->pipe = pi;
    8000510e:	609c                	ld	a5,0(s1)
    80005110:	0127b823          	sd	s2,16(a5)
  (*f1)->type = FD_PIPE;
    80005114:	000a3783          	ld	a5,0(s4)
    80005118:	0137a023          	sw	s3,0(a5)
  (*f1)->readable = 0;
    8000511c:	000a3783          	ld	a5,0(s4)
    80005120:	00078423          	sb	zero,8(a5)
  (*f1)->writable = 1;
    80005124:	000a3783          	ld	a5,0(s4)
    80005128:	013784a3          	sb	s3,9(a5)
  (*f1)->pipe = pi;
    8000512c:	000a3783          	ld	a5,0(s4)
    80005130:	0127b823          	sd	s2,16(a5)
  return 0;
    80005134:	4501                	li	a0,0
    80005136:	a025                	j	8000515e <pipealloc+0xc6>

 bad:
  if(pi)
    kfree((char*)pi);
  if(*f0)
    80005138:	6088                	ld	a0,0(s1)
    8000513a:	e501                	bnez	a0,80005142 <pipealloc+0xaa>
    8000513c:	a039                	j	8000514a <pipealloc+0xb2>
    8000513e:	6088                	ld	a0,0(s1)
    80005140:	c51d                	beqz	a0,8000516e <pipealloc+0xd6>
    fileclose(*f0);
    80005142:	00000097          	auipc	ra,0x0
    80005146:	c26080e7          	jalr	-986(ra) # 80004d68 <fileclose>
  if(*f1)
    8000514a:	000a3783          	ld	a5,0(s4)
    fileclose(*f1);
  return -1;
    8000514e:	557d                	li	a0,-1
  if(*f1)
    80005150:	c799                	beqz	a5,8000515e <pipealloc+0xc6>
    fileclose(*f1);
    80005152:	853e                	mv	a0,a5
    80005154:	00000097          	auipc	ra,0x0
    80005158:	c14080e7          	jalr	-1004(ra) # 80004d68 <fileclose>
  return -1;
    8000515c:	557d                	li	a0,-1
}
    8000515e:	70a2                	ld	ra,40(sp)
    80005160:	7402                	ld	s0,32(sp)
    80005162:	64e2                	ld	s1,24(sp)
    80005164:	6942                	ld	s2,16(sp)
    80005166:	69a2                	ld	s3,8(sp)
    80005168:	6a02                	ld	s4,0(sp)
    8000516a:	6145                	addi	sp,sp,48
    8000516c:	8082                	ret
  return -1;
    8000516e:	557d                	li	a0,-1
    80005170:	b7fd                	j	8000515e <pipealloc+0xc6>

0000000080005172 <pipeclose>:

void
pipeclose(struct pipe *pi, int writable)
{
    80005172:	1101                	addi	sp,sp,-32
    80005174:	ec06                	sd	ra,24(sp)
    80005176:	e822                	sd	s0,16(sp)
    80005178:	e426                	sd	s1,8(sp)
    8000517a:	e04a                	sd	s2,0(sp)
    8000517c:	1000                	addi	s0,sp,32
    8000517e:	84aa                	mv	s1,a0
    80005180:	892e                	mv	s2,a1
  acquire(&pi->lock);
    80005182:	ffffc097          	auipc	ra,0xffffc
    80005186:	a40080e7          	jalr	-1472(ra) # 80000bc2 <acquire>
  if(writable){
    8000518a:	02090d63          	beqz	s2,800051c4 <pipeclose+0x52>
    pi->writeopen = 0;
    8000518e:	2204a223          	sw	zero,548(s1)
    wakeup(&pi->nread);
    80005192:	21848513          	addi	a0,s1,536
    80005196:	ffffd097          	auipc	ra,0xffffd
    8000519a:	1ac080e7          	jalr	428(ra) # 80002342 <wakeup>
  } else {
    pi->readopen = 0;
    wakeup(&pi->nwrite);
  }
  if(pi->readopen == 0 && pi->writeopen == 0){
    8000519e:	2204b783          	ld	a5,544(s1)
    800051a2:	eb95                	bnez	a5,800051d6 <pipeclose+0x64>
    release(&pi->lock);
    800051a4:	8526                	mv	a0,s1
    800051a6:	ffffc097          	auipc	ra,0xffffc
    800051aa:	ad0080e7          	jalr	-1328(ra) # 80000c76 <release>
    kfree((char*)pi);
    800051ae:	8526                	mv	a0,s1
    800051b0:	ffffc097          	auipc	ra,0xffffc
    800051b4:	824080e7          	jalr	-2012(ra) # 800009d4 <kfree>
  } else
    release(&pi->lock);
}
    800051b8:	60e2                	ld	ra,24(sp)
    800051ba:	6442                	ld	s0,16(sp)
    800051bc:	64a2                	ld	s1,8(sp)
    800051be:	6902                	ld	s2,0(sp)
    800051c0:	6105                	addi	sp,sp,32
    800051c2:	8082                	ret
    pi->readopen = 0;
    800051c4:	2204a023          	sw	zero,544(s1)
    wakeup(&pi->nwrite);
    800051c8:	21c48513          	addi	a0,s1,540
    800051cc:	ffffd097          	auipc	ra,0xffffd
    800051d0:	176080e7          	jalr	374(ra) # 80002342 <wakeup>
    800051d4:	b7e9                	j	8000519e <pipeclose+0x2c>
    release(&pi->lock);
    800051d6:	8526                	mv	a0,s1
    800051d8:	ffffc097          	auipc	ra,0xffffc
    800051dc:	a9e080e7          	jalr	-1378(ra) # 80000c76 <release>
}
    800051e0:	bfe1                	j	800051b8 <pipeclose+0x46>

00000000800051e2 <pipewrite>:

int
pipewrite(struct pipe *pi, uint64 addr, int n)
{
    800051e2:	711d                	addi	sp,sp,-96
    800051e4:	ec86                	sd	ra,88(sp)
    800051e6:	e8a2                	sd	s0,80(sp)
    800051e8:	e4a6                	sd	s1,72(sp)
    800051ea:	e0ca                	sd	s2,64(sp)
    800051ec:	fc4e                	sd	s3,56(sp)
    800051ee:	f852                	sd	s4,48(sp)
    800051f0:	f456                	sd	s5,40(sp)
    800051f2:	f05a                	sd	s6,32(sp)
    800051f4:	ec5e                	sd	s7,24(sp)
    800051f6:	e862                	sd	s8,16(sp)
    800051f8:	1080                	addi	s0,sp,96
    800051fa:	84aa                	mv	s1,a0
    800051fc:	8aae                	mv	s5,a1
    800051fe:	8a32                	mv	s4,a2
  int i = 0;
  struct proc *pr = myproc();
    80005200:	ffffc097          	auipc	ra,0xffffc
    80005204:	7aa080e7          	jalr	1962(ra) # 800019aa <myproc>
    80005208:	89aa                	mv	s3,a0

  acquire(&pi->lock);
    8000520a:	8526                	mv	a0,s1
    8000520c:	ffffc097          	auipc	ra,0xffffc
    80005210:	9b6080e7          	jalr	-1610(ra) # 80000bc2 <acquire>
  while(i < n){
    80005214:	0b405363          	blez	s4,800052ba <pipewrite+0xd8>
  int i = 0;
    80005218:	4901                	li	s2,0
    if(pi->nwrite == pi->nread + PIPESIZE){ //DOC: pipewrite-full
      wakeup(&pi->nread);
      sleep(&pi->nwrite, &pi->lock);
    } else {
      char ch;
      if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    8000521a:	5b7d                	li	s6,-1
      wakeup(&pi->nread);
    8000521c:	21848c13          	addi	s8,s1,536
      sleep(&pi->nwrite, &pi->lock);
    80005220:	21c48b93          	addi	s7,s1,540
    80005224:	a089                	j	80005266 <pipewrite+0x84>
      release(&pi->lock);
    80005226:	8526                	mv	a0,s1
    80005228:	ffffc097          	auipc	ra,0xffffc
    8000522c:	a4e080e7          	jalr	-1458(ra) # 80000c76 <release>
      return -1;
    80005230:	597d                	li	s2,-1
  }
  wakeup(&pi->nread);
  release(&pi->lock);

  return i;
}
    80005232:	854a                	mv	a0,s2
    80005234:	60e6                	ld	ra,88(sp)
    80005236:	6446                	ld	s0,80(sp)
    80005238:	64a6                	ld	s1,72(sp)
    8000523a:	6906                	ld	s2,64(sp)
    8000523c:	79e2                	ld	s3,56(sp)
    8000523e:	7a42                	ld	s4,48(sp)
    80005240:	7aa2                	ld	s5,40(sp)
    80005242:	7b02                	ld	s6,32(sp)
    80005244:	6be2                	ld	s7,24(sp)
    80005246:	6c42                	ld	s8,16(sp)
    80005248:	6125                	addi	sp,sp,96
    8000524a:	8082                	ret
      wakeup(&pi->nread);
    8000524c:	8562                	mv	a0,s8
    8000524e:	ffffd097          	auipc	ra,0xffffd
    80005252:	0f4080e7          	jalr	244(ra) # 80002342 <wakeup>
      sleep(&pi->nwrite, &pi->lock);
    80005256:	85a6                	mv	a1,s1
    80005258:	855e                	mv	a0,s7
    8000525a:	ffffd097          	auipc	ra,0xffffd
    8000525e:	f68080e7          	jalr	-152(ra) # 800021c2 <sleep>
  while(i < n){
    80005262:	05495d63          	bge	s2,s4,800052bc <pipewrite+0xda>
    if(pi->readopen == 0 || pr->killed){
    80005266:	2204a783          	lw	a5,544(s1)
    8000526a:	dfd5                	beqz	a5,80005226 <pipewrite+0x44>
    8000526c:	0309a783          	lw	a5,48(s3)
    80005270:	fbdd                	bnez	a5,80005226 <pipewrite+0x44>
    if(pi->nwrite == pi->nread + PIPESIZE){ //DOC: pipewrite-full
    80005272:	2184a783          	lw	a5,536(s1)
    80005276:	21c4a703          	lw	a4,540(s1)
    8000527a:	2007879b          	addiw	a5,a5,512
    8000527e:	fcf707e3          	beq	a4,a5,8000524c <pipewrite+0x6a>
      if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80005282:	4685                	li	a3,1
    80005284:	01590633          	add	a2,s2,s5
    80005288:	faf40593          	addi	a1,s0,-81
    8000528c:	0509b503          	ld	a0,80(s3)
    80005290:	ffffc097          	auipc	ra,0xffffc
    80005294:	43e080e7          	jalr	1086(ra) # 800016ce <copyin>
    80005298:	03650263          	beq	a0,s6,800052bc <pipewrite+0xda>
      pi->data[pi->nwrite++ % PIPESIZE] = ch;
    8000529c:	21c4a783          	lw	a5,540(s1)
    800052a0:	0017871b          	addiw	a4,a5,1
    800052a4:	20e4ae23          	sw	a4,540(s1)
    800052a8:	1ff7f793          	andi	a5,a5,511
    800052ac:	97a6                	add	a5,a5,s1
    800052ae:	faf44703          	lbu	a4,-81(s0)
    800052b2:	00e78c23          	sb	a4,24(a5)
      i++;
    800052b6:	2905                	addiw	s2,s2,1
    800052b8:	b76d                	j	80005262 <pipewrite+0x80>
  int i = 0;
    800052ba:	4901                	li	s2,0
  wakeup(&pi->nread);
    800052bc:	21848513          	addi	a0,s1,536
    800052c0:	ffffd097          	auipc	ra,0xffffd
    800052c4:	082080e7          	jalr	130(ra) # 80002342 <wakeup>
  release(&pi->lock);
    800052c8:	8526                	mv	a0,s1
    800052ca:	ffffc097          	auipc	ra,0xffffc
    800052ce:	9ac080e7          	jalr	-1620(ra) # 80000c76 <release>
  return i;
    800052d2:	b785                	j	80005232 <pipewrite+0x50>

00000000800052d4 <piperead>:

int
piperead(struct pipe *pi, uint64 addr, int n)
{
    800052d4:	715d                	addi	sp,sp,-80
    800052d6:	e486                	sd	ra,72(sp)
    800052d8:	e0a2                	sd	s0,64(sp)
    800052da:	fc26                	sd	s1,56(sp)
    800052dc:	f84a                	sd	s2,48(sp)
    800052de:	f44e                	sd	s3,40(sp)
    800052e0:	f052                	sd	s4,32(sp)
    800052e2:	ec56                	sd	s5,24(sp)
    800052e4:	e85a                	sd	s6,16(sp)
    800052e6:	0880                	addi	s0,sp,80
    800052e8:	84aa                	mv	s1,a0
    800052ea:	892e                	mv	s2,a1
    800052ec:	8ab2                	mv	s5,a2
  int i;
  struct proc *pr = myproc();
    800052ee:	ffffc097          	auipc	ra,0xffffc
    800052f2:	6bc080e7          	jalr	1724(ra) # 800019aa <myproc>
    800052f6:	8a2a                	mv	s4,a0
  char ch;

  acquire(&pi->lock);
    800052f8:	8526                	mv	a0,s1
    800052fa:	ffffc097          	auipc	ra,0xffffc
    800052fe:	8c8080e7          	jalr	-1848(ra) # 80000bc2 <acquire>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80005302:	2184a703          	lw	a4,536(s1)
    80005306:	21c4a783          	lw	a5,540(s1)
    if(pr->killed){
      release(&pi->lock);
      return -1;
    }
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    8000530a:	21848993          	addi	s3,s1,536
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    8000530e:	02f71463          	bne	a4,a5,80005336 <piperead+0x62>
    80005312:	2244a783          	lw	a5,548(s1)
    80005316:	c385                	beqz	a5,80005336 <piperead+0x62>
    if(pr->killed){
    80005318:	030a2783          	lw	a5,48(s4)
    8000531c:	ebc9                	bnez	a5,800053ae <piperead+0xda>
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    8000531e:	85a6                	mv	a1,s1
    80005320:	854e                	mv	a0,s3
    80005322:	ffffd097          	auipc	ra,0xffffd
    80005326:	ea0080e7          	jalr	-352(ra) # 800021c2 <sleep>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    8000532a:	2184a703          	lw	a4,536(s1)
    8000532e:	21c4a783          	lw	a5,540(s1)
    80005332:	fef700e3          	beq	a4,a5,80005312 <piperead+0x3e>
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80005336:	4981                	li	s3,0
    if(pi->nread == pi->nwrite)
      break;
    ch = pi->data[pi->nread++ % PIPESIZE];
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80005338:	5b7d                	li	s6,-1
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    8000533a:	05505463          	blez	s5,80005382 <piperead+0xae>
    if(pi->nread == pi->nwrite)
    8000533e:	2184a783          	lw	a5,536(s1)
    80005342:	21c4a703          	lw	a4,540(s1)
    80005346:	02f70e63          	beq	a4,a5,80005382 <piperead+0xae>
    ch = pi->data[pi->nread++ % PIPESIZE];
    8000534a:	0017871b          	addiw	a4,a5,1
    8000534e:	20e4ac23          	sw	a4,536(s1)
    80005352:	1ff7f793          	andi	a5,a5,511
    80005356:	97a6                	add	a5,a5,s1
    80005358:	0187c783          	lbu	a5,24(a5)
    8000535c:	faf40fa3          	sb	a5,-65(s0)
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80005360:	4685                	li	a3,1
    80005362:	fbf40613          	addi	a2,s0,-65
    80005366:	85ca                	mv	a1,s2
    80005368:	050a3503          	ld	a0,80(s4)
    8000536c:	ffffc097          	auipc	ra,0xffffc
    80005370:	2d6080e7          	jalr	726(ra) # 80001642 <copyout>
    80005374:	01650763          	beq	a0,s6,80005382 <piperead+0xae>
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80005378:	2985                	addiw	s3,s3,1
    8000537a:	0905                	addi	s2,s2,1
    8000537c:	fd3a91e3          	bne	s5,s3,8000533e <piperead+0x6a>
    80005380:	89d6                	mv	s3,s5
      break;
  }
  wakeup(&pi->nwrite);  //DOC: piperead-wakeup
    80005382:	21c48513          	addi	a0,s1,540
    80005386:	ffffd097          	auipc	ra,0xffffd
    8000538a:	fbc080e7          	jalr	-68(ra) # 80002342 <wakeup>
  release(&pi->lock);
    8000538e:	8526                	mv	a0,s1
    80005390:	ffffc097          	auipc	ra,0xffffc
    80005394:	8e6080e7          	jalr	-1818(ra) # 80000c76 <release>
  return i;
}
    80005398:	854e                	mv	a0,s3
    8000539a:	60a6                	ld	ra,72(sp)
    8000539c:	6406                	ld	s0,64(sp)
    8000539e:	74e2                	ld	s1,56(sp)
    800053a0:	7942                	ld	s2,48(sp)
    800053a2:	79a2                	ld	s3,40(sp)
    800053a4:	7a02                	ld	s4,32(sp)
    800053a6:	6ae2                	ld	s5,24(sp)
    800053a8:	6b42                	ld	s6,16(sp)
    800053aa:	6161                	addi	sp,sp,80
    800053ac:	8082                	ret
      release(&pi->lock);
    800053ae:	8526                	mv	a0,s1
    800053b0:	ffffc097          	auipc	ra,0xffffc
    800053b4:	8c6080e7          	jalr	-1850(ra) # 80000c76 <release>
      return -1;
    800053b8:	59fd                	li	s3,-1
    800053ba:	bff9                	j	80005398 <piperead+0xc4>

00000000800053bc <exec>:

static int loadseg(pde_t *pgdir, uint64 addr, struct inode *ip, uint offset, uint sz);

int
exec(char *path, char **argv)
{
    800053bc:	de010113          	addi	sp,sp,-544
    800053c0:	20113c23          	sd	ra,536(sp)
    800053c4:	20813823          	sd	s0,528(sp)
    800053c8:	20913423          	sd	s1,520(sp)
    800053cc:	21213023          	sd	s2,512(sp)
    800053d0:	ffce                	sd	s3,504(sp)
    800053d2:	fbd2                	sd	s4,496(sp)
    800053d4:	f7d6                	sd	s5,488(sp)
    800053d6:	f3da                	sd	s6,480(sp)
    800053d8:	efde                	sd	s7,472(sp)
    800053da:	ebe2                	sd	s8,464(sp)
    800053dc:	e7e6                	sd	s9,456(sp)
    800053de:	e3ea                	sd	s10,448(sp)
    800053e0:	ff6e                	sd	s11,440(sp)
    800053e2:	1400                	addi	s0,sp,544
    800053e4:	892a                	mv	s2,a0
    800053e6:	dea43423          	sd	a0,-536(s0)
    800053ea:	deb43823          	sd	a1,-528(s0)
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
  struct elfhdr elf;
  struct inode *ip;
  struct proghdr ph;
  pagetable_t pagetable = 0, oldpagetable;
  struct proc *p = myproc();
    800053ee:	ffffc097          	auipc	ra,0xffffc
    800053f2:	5bc080e7          	jalr	1468(ra) # 800019aa <myproc>
    800053f6:	84aa                	mv	s1,a0

  begin_op();
    800053f8:	fffff097          	auipc	ra,0xfffff
    800053fc:	4a0080e7          	jalr	1184(ra) # 80004898 <begin_op>

  if((ip = namei(path)) == 0){
    80005400:	854a                	mv	a0,s2
    80005402:	fffff097          	auipc	ra,0xfffff
    80005406:	276080e7          	jalr	630(ra) # 80004678 <namei>
    8000540a:	c93d                	beqz	a0,80005480 <exec+0xc4>
    8000540c:	8aaa                	mv	s5,a0
    end_op();
    return -1;
  }
  ilock(ip);
    8000540e:	ffffe097          	auipc	ra,0xffffe
    80005412:	296080e7          	jalr	662(ra) # 800036a4 <ilock>

  // Check ELF header
  if(readi(ip, 0, (uint64)&elf, 0, sizeof(elf)) != sizeof(elf))
    80005416:	04000713          	li	a4,64
    8000541a:	4681                	li	a3,0
    8000541c:	e4840613          	addi	a2,s0,-440
    80005420:	4581                	li	a1,0
    80005422:	8556                	mv	a0,s5
    80005424:	ffffe097          	auipc	ra,0xffffe
    80005428:	5da080e7          	jalr	1498(ra) # 800039fe <readi>
    8000542c:	04000793          	li	a5,64
    80005430:	00f51a63          	bne	a0,a5,80005444 <exec+0x88>
    goto bad;
  if(elf.magic != ELF_MAGIC)
    80005434:	e4842703          	lw	a4,-440(s0)
    80005438:	464c47b7          	lui	a5,0x464c4
    8000543c:	57f78793          	addi	a5,a5,1407 # 464c457f <_entry-0x39b3ba81>
    80005440:	04f70663          	beq	a4,a5,8000548c <exec+0xd0>

 bad:
  if(pagetable)
    proc_freepagetable(pagetable, sz);
  if(ip){
    iunlockput(ip);
    80005444:	8556                	mv	a0,s5
    80005446:	ffffe097          	auipc	ra,0xffffe
    8000544a:	566080e7          	jalr	1382(ra) # 800039ac <iunlockput>
    end_op();
    8000544e:	fffff097          	auipc	ra,0xfffff
    80005452:	4c8080e7          	jalr	1224(ra) # 80004916 <end_op>
  }
  return -1;
    80005456:	557d                	li	a0,-1
}
    80005458:	21813083          	ld	ra,536(sp)
    8000545c:	21013403          	ld	s0,528(sp)
    80005460:	20813483          	ld	s1,520(sp)
    80005464:	20013903          	ld	s2,512(sp)
    80005468:	79fe                	ld	s3,504(sp)
    8000546a:	7a5e                	ld	s4,496(sp)
    8000546c:	7abe                	ld	s5,488(sp)
    8000546e:	7b1e                	ld	s6,480(sp)
    80005470:	6bfe                	ld	s7,472(sp)
    80005472:	6c5e                	ld	s8,464(sp)
    80005474:	6cbe                	ld	s9,456(sp)
    80005476:	6d1e                	ld	s10,448(sp)
    80005478:	7dfa                	ld	s11,440(sp)
    8000547a:	22010113          	addi	sp,sp,544
    8000547e:	8082                	ret
    end_op();
    80005480:	fffff097          	auipc	ra,0xfffff
    80005484:	496080e7          	jalr	1174(ra) # 80004916 <end_op>
    return -1;
    80005488:	557d                	li	a0,-1
    8000548a:	b7f9                	j	80005458 <exec+0x9c>
  if((pagetable = proc_pagetable(p)) == 0)
    8000548c:	8526                	mv	a0,s1
    8000548e:	ffffc097          	auipc	ra,0xffffc
    80005492:	5e0080e7          	jalr	1504(ra) # 80001a6e <proc_pagetable>
    80005496:	8b2a                	mv	s6,a0
    80005498:	d555                	beqz	a0,80005444 <exec+0x88>
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    8000549a:	e6842783          	lw	a5,-408(s0)
    8000549e:	e8045703          	lhu	a4,-384(s0)
    800054a2:	c735                	beqz	a4,8000550e <exec+0x152>
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
    800054a4:	4481                	li	s1,0
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    800054a6:	e0043423          	sd	zero,-504(s0)
    if(ph.vaddr % PGSIZE != 0)
    800054aa:	6a05                	lui	s4,0x1
    800054ac:	fffa0713          	addi	a4,s4,-1 # fff <_entry-0x7ffff001>
    800054b0:	dee43023          	sd	a4,-544(s0)
  uint64 pa;

  if((va % PGSIZE) != 0)
    panic("loadseg: va must be page aligned");

  for(i = 0; i < sz; i += PGSIZE){
    800054b4:	6d85                	lui	s11,0x1
    800054b6:	7d7d                	lui	s10,0xfffff
    800054b8:	ac1d                	j	800056ee <exec+0x332>
    pa = walkaddr(pagetable, va + i);
    if(pa == 0)
      panic("loadseg: address should exist");
    800054ba:	00003517          	auipc	a0,0x3
    800054be:	1be50513          	addi	a0,a0,446 # 80008678 <syscalls+0x258>
    800054c2:	ffffb097          	auipc	ra,0xffffb
    800054c6:	06a080e7          	jalr	106(ra) # 8000052c <panic>
    if(sz - i < PGSIZE)
      n = sz - i;
    else
      n = PGSIZE;
    if(readi(ip, 0, (uint64)pa, offset+i, n) != n)
    800054ca:	874a                	mv	a4,s2
    800054cc:	009c86bb          	addw	a3,s9,s1
    800054d0:	4581                	li	a1,0
    800054d2:	8556                	mv	a0,s5
    800054d4:	ffffe097          	auipc	ra,0xffffe
    800054d8:	52a080e7          	jalr	1322(ra) # 800039fe <readi>
    800054dc:	2501                	sext.w	a0,a0
    800054de:	1aa91863          	bne	s2,a0,8000568e <exec+0x2d2>
  for(i = 0; i < sz; i += PGSIZE){
    800054e2:	009d84bb          	addw	s1,s11,s1
    800054e6:	013d09bb          	addw	s3,s10,s3
    800054ea:	1f74f263          	bgeu	s1,s7,800056ce <exec+0x312>
    pa = walkaddr(pagetable, va + i);
    800054ee:	02049593          	slli	a1,s1,0x20
    800054f2:	9181                	srli	a1,a1,0x20
    800054f4:	95e2                	add	a1,a1,s8
    800054f6:	855a                	mv	a0,s6
    800054f8:	ffffc097          	auipc	ra,0xffffc
    800054fc:	b54080e7          	jalr	-1196(ra) # 8000104c <walkaddr>
    80005500:	862a                	mv	a2,a0
    if(pa == 0)
    80005502:	dd45                	beqz	a0,800054ba <exec+0xfe>
      n = PGSIZE;
    80005504:	8952                	mv	s2,s4
    if(sz - i < PGSIZE)
    80005506:	fd49f2e3          	bgeu	s3,s4,800054ca <exec+0x10e>
      n = sz - i;
    8000550a:	894e                	mv	s2,s3
    8000550c:	bf7d                	j	800054ca <exec+0x10e>
  uint64 argc, sz = 0, sp, ustack[MAXARG+1], stackbase;
    8000550e:	4481                	li	s1,0
  iunlockput(ip);
    80005510:	8556                	mv	a0,s5
    80005512:	ffffe097          	auipc	ra,0xffffe
    80005516:	49a080e7          	jalr	1178(ra) # 800039ac <iunlockput>
  end_op();
    8000551a:	fffff097          	auipc	ra,0xfffff
    8000551e:	3fc080e7          	jalr	1020(ra) # 80004916 <end_op>
  p = myproc();
    80005522:	ffffc097          	auipc	ra,0xffffc
    80005526:	488080e7          	jalr	1160(ra) # 800019aa <myproc>
    8000552a:	8baa                	mv	s7,a0
  uint64 oldsz = p->sz;
    8000552c:	04853d03          	ld	s10,72(a0)
  sz = PGROUNDUP(sz);
    80005530:	6785                	lui	a5,0x1
    80005532:	17fd                	addi	a5,a5,-1 # fff <_entry-0x7ffff001>
    80005534:	97a6                	add	a5,a5,s1
    80005536:	777d                	lui	a4,0xfffff
    80005538:	8ff9                	and	a5,a5,a4
    8000553a:	def43c23          	sd	a5,-520(s0)
  if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    8000553e:	6609                	lui	a2,0x2
    80005540:	963e                	add	a2,a2,a5
    80005542:	85be                	mv	a1,a5
    80005544:	855a                	mv	a0,s6
    80005546:	ffffc097          	auipc	ra,0xffffc
    8000554a:	ea8080e7          	jalr	-344(ra) # 800013ee <uvmalloc>
    8000554e:	8c2a                	mv	s8,a0
  ip = 0;
    80005550:	4a81                	li	s5,0
  if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80005552:	12050e63          	beqz	a0,8000568e <exec+0x2d2>
  uvmclear(pagetable, sz-2*PGSIZE);
    80005556:	75f9                	lui	a1,0xffffe
    80005558:	95aa                	add	a1,a1,a0
    8000555a:	855a                	mv	a0,s6
    8000555c:	ffffc097          	auipc	ra,0xffffc
    80005560:	0b4080e7          	jalr	180(ra) # 80001610 <uvmclear>
  stackbase = sp - PGSIZE;
    80005564:	7afd                	lui	s5,0xfffff
    80005566:	9ae2                	add	s5,s5,s8
  for(argc = 0; argv[argc]; argc++) {
    80005568:	df043783          	ld	a5,-528(s0)
    8000556c:	6388                	ld	a0,0(a5)
    8000556e:	c925                	beqz	a0,800055de <exec+0x222>
    80005570:	e8840993          	addi	s3,s0,-376
    80005574:	f8840c93          	addi	s9,s0,-120
  sp = sz;
    80005578:	8962                	mv	s2,s8
  for(argc = 0; argv[argc]; argc++) {
    8000557a:	4481                	li	s1,0
    sp -= strlen(argv[argc]) + 1;
    8000557c:	ffffc097          	auipc	ra,0xffffc
    80005580:	8c6080e7          	jalr	-1850(ra) # 80000e42 <strlen>
    80005584:	0015079b          	addiw	a5,a0,1
    80005588:	40f907b3          	sub	a5,s2,a5
    sp -= sp % 16; // riscv sp must be 16-byte aligned
    8000558c:	ff07f913          	andi	s2,a5,-16
    if(sp < stackbase)
    80005590:	13596363          	bltu	s2,s5,800056b6 <exec+0x2fa>
    if(copyout(pagetable, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
    80005594:	df043d83          	ld	s11,-528(s0)
    80005598:	000dba03          	ld	s4,0(s11) # 1000 <_entry-0x7ffff000>
    8000559c:	8552                	mv	a0,s4
    8000559e:	ffffc097          	auipc	ra,0xffffc
    800055a2:	8a4080e7          	jalr	-1884(ra) # 80000e42 <strlen>
    800055a6:	0015069b          	addiw	a3,a0,1
    800055aa:	8652                	mv	a2,s4
    800055ac:	85ca                	mv	a1,s2
    800055ae:	855a                	mv	a0,s6
    800055b0:	ffffc097          	auipc	ra,0xffffc
    800055b4:	092080e7          	jalr	146(ra) # 80001642 <copyout>
    800055b8:	10054363          	bltz	a0,800056be <exec+0x302>
    ustack[argc] = sp;
    800055bc:	0129b023          	sd	s2,0(s3)
  for(argc = 0; argv[argc]; argc++) {
    800055c0:	0485                	addi	s1,s1,1
    800055c2:	008d8793          	addi	a5,s11,8
    800055c6:	def43823          	sd	a5,-528(s0)
    800055ca:	008db503          	ld	a0,8(s11)
    800055ce:	c911                	beqz	a0,800055e2 <exec+0x226>
    if(argc >= MAXARG)
    800055d0:	09a1                	addi	s3,s3,8
    800055d2:	fb3c95e3          	bne	s9,s3,8000557c <exec+0x1c0>
  sz = sz1;
    800055d6:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    800055da:	4a81                	li	s5,0
    800055dc:	a84d                	j	8000568e <exec+0x2d2>
  sp = sz;
    800055de:	8962                	mv	s2,s8
  for(argc = 0; argv[argc]; argc++) {
    800055e0:	4481                	li	s1,0
  ustack[argc] = 0;
    800055e2:	00349793          	slli	a5,s1,0x3
    800055e6:	f9078793          	addi	a5,a5,-112
    800055ea:	97a2                	add	a5,a5,s0
    800055ec:	ee07bc23          	sd	zero,-264(a5)
  sp -= (argc+1) * sizeof(uint64);
    800055f0:	00148693          	addi	a3,s1,1
    800055f4:	068e                	slli	a3,a3,0x3
    800055f6:	40d90933          	sub	s2,s2,a3
  sp -= sp % 16;
    800055fa:	ff097913          	andi	s2,s2,-16
  if(sp < stackbase)
    800055fe:	01597663          	bgeu	s2,s5,8000560a <exec+0x24e>
  sz = sz1;
    80005602:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    80005606:	4a81                	li	s5,0
    80005608:	a059                	j	8000568e <exec+0x2d2>
  if(copyout(pagetable, sp, (char *)ustack, (argc+1)*sizeof(uint64)) < 0)
    8000560a:	e8840613          	addi	a2,s0,-376
    8000560e:	85ca                	mv	a1,s2
    80005610:	855a                	mv	a0,s6
    80005612:	ffffc097          	auipc	ra,0xffffc
    80005616:	030080e7          	jalr	48(ra) # 80001642 <copyout>
    8000561a:	0a054663          	bltz	a0,800056c6 <exec+0x30a>
  p->trapframe->a1 = sp;
    8000561e:	058bb783          	ld	a5,88(s7)
    80005622:	0727bc23          	sd	s2,120(a5)
  for(last=s=path; *s; s++)
    80005626:	de843783          	ld	a5,-536(s0)
    8000562a:	0007c703          	lbu	a4,0(a5)
    8000562e:	cf11                	beqz	a4,8000564a <exec+0x28e>
    80005630:	0785                	addi	a5,a5,1
    if(*s == '/')
    80005632:	02f00693          	li	a3,47
    80005636:	a039                	j	80005644 <exec+0x288>
      last = s+1;
    80005638:	def43423          	sd	a5,-536(s0)
  for(last=s=path; *s; s++)
    8000563c:	0785                	addi	a5,a5,1
    8000563e:	fff7c703          	lbu	a4,-1(a5)
    80005642:	c701                	beqz	a4,8000564a <exec+0x28e>
    if(*s == '/')
    80005644:	fed71ce3          	bne	a4,a3,8000563c <exec+0x280>
    80005648:	bfc5                	j	80005638 <exec+0x27c>
  safestrcpy(p->name, last, sizeof(p->name));
    8000564a:	4641                	li	a2,16
    8000564c:	de843583          	ld	a1,-536(s0)
    80005650:	158b8513          	addi	a0,s7,344
    80005654:	ffffb097          	auipc	ra,0xffffb
    80005658:	7bc080e7          	jalr	1980(ra) # 80000e10 <safestrcpy>
  oldpagetable = p->pagetable;
    8000565c:	050bb503          	ld	a0,80(s7)
  p->pagetable = pagetable;
    80005660:	056bb823          	sd	s6,80(s7)
  p->sz = sz;
    80005664:	058bb423          	sd	s8,72(s7)
  p->trapframe->epc = elf.entry;  // initial program counter = main
    80005668:	058bb783          	ld	a5,88(s7)
    8000566c:	e6043703          	ld	a4,-416(s0)
    80005670:	ef98                	sd	a4,24(a5)
  p->trapframe->sp = sp; // initial stack pointer
    80005672:	058bb783          	ld	a5,88(s7)
    80005676:	0327b823          	sd	s2,48(a5)
  proc_freepagetable(oldpagetable, oldsz);
    8000567a:	85ea                	mv	a1,s10
    8000567c:	ffffc097          	auipc	ra,0xffffc
    80005680:	48e080e7          	jalr	1166(ra) # 80001b0a <proc_freepagetable>
  return argc; // this ends up in a0, the first argument to main(argc, argv)
    80005684:	0004851b          	sext.w	a0,s1
    80005688:	bbc1                	j	80005458 <exec+0x9c>
    8000568a:	de943c23          	sd	s1,-520(s0)
    proc_freepagetable(pagetable, sz);
    8000568e:	df843583          	ld	a1,-520(s0)
    80005692:	855a                	mv	a0,s6
    80005694:	ffffc097          	auipc	ra,0xffffc
    80005698:	476080e7          	jalr	1142(ra) # 80001b0a <proc_freepagetable>
  if(ip){
    8000569c:	da0a94e3          	bnez	s5,80005444 <exec+0x88>
  return -1;
    800056a0:	557d                	li	a0,-1
    800056a2:	bb5d                	j	80005458 <exec+0x9c>
    800056a4:	de943c23          	sd	s1,-520(s0)
    800056a8:	b7dd                	j	8000568e <exec+0x2d2>
    800056aa:	de943c23          	sd	s1,-520(s0)
    800056ae:	b7c5                	j	8000568e <exec+0x2d2>
    800056b0:	de943c23          	sd	s1,-520(s0)
    800056b4:	bfe9                	j	8000568e <exec+0x2d2>
  sz = sz1;
    800056b6:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    800056ba:	4a81                	li	s5,0
    800056bc:	bfc9                	j	8000568e <exec+0x2d2>
  sz = sz1;
    800056be:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    800056c2:	4a81                	li	s5,0
    800056c4:	b7e9                	j	8000568e <exec+0x2d2>
  sz = sz1;
    800056c6:	df843c23          	sd	s8,-520(s0)
  ip = 0;
    800056ca:	4a81                	li	s5,0
    800056cc:	b7c9                	j	8000568e <exec+0x2d2>
    if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    800056ce:	df843483          	ld	s1,-520(s0)
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    800056d2:	e0843783          	ld	a5,-504(s0)
    800056d6:	0017869b          	addiw	a3,a5,1
    800056da:	e0d43423          	sd	a3,-504(s0)
    800056de:	e0043783          	ld	a5,-512(s0)
    800056e2:	0387879b          	addiw	a5,a5,56
    800056e6:	e8045703          	lhu	a4,-384(s0)
    800056ea:	e2e6d3e3          	bge	a3,a4,80005510 <exec+0x154>
    if(readi(ip, 0, (uint64)&ph, off, sizeof(ph)) != sizeof(ph))
    800056ee:	2781                	sext.w	a5,a5
    800056f0:	e0f43023          	sd	a5,-512(s0)
    800056f4:	03800713          	li	a4,56
    800056f8:	86be                	mv	a3,a5
    800056fa:	e1040613          	addi	a2,s0,-496
    800056fe:	4581                	li	a1,0
    80005700:	8556                	mv	a0,s5
    80005702:	ffffe097          	auipc	ra,0xffffe
    80005706:	2fc080e7          	jalr	764(ra) # 800039fe <readi>
    8000570a:	03800793          	li	a5,56
    8000570e:	f6f51ee3          	bne	a0,a5,8000568a <exec+0x2ce>
    if(ph.type != ELF_PROG_LOAD)
    80005712:	e1042783          	lw	a5,-496(s0)
    80005716:	4705                	li	a4,1
    80005718:	fae79de3          	bne	a5,a4,800056d2 <exec+0x316>
    if(ph.memsz < ph.filesz)
    8000571c:	e3843603          	ld	a2,-456(s0)
    80005720:	e3043783          	ld	a5,-464(s0)
    80005724:	f8f660e3          	bltu	a2,a5,800056a4 <exec+0x2e8>
    if(ph.vaddr + ph.memsz < ph.vaddr)
    80005728:	e2043783          	ld	a5,-480(s0)
    8000572c:	963e                	add	a2,a2,a5
    8000572e:	f6f66ee3          	bltu	a2,a5,800056aa <exec+0x2ee>
    if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    80005732:	85a6                	mv	a1,s1
    80005734:	855a                	mv	a0,s6
    80005736:	ffffc097          	auipc	ra,0xffffc
    8000573a:	cb8080e7          	jalr	-840(ra) # 800013ee <uvmalloc>
    8000573e:	dea43c23          	sd	a0,-520(s0)
    80005742:	d53d                	beqz	a0,800056b0 <exec+0x2f4>
    if(ph.vaddr % PGSIZE != 0)
    80005744:	e2043c03          	ld	s8,-480(s0)
    80005748:	de043783          	ld	a5,-544(s0)
    8000574c:	00fc77b3          	and	a5,s8,a5
    80005750:	ff9d                	bnez	a5,8000568e <exec+0x2d2>
    if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0)
    80005752:	e1842c83          	lw	s9,-488(s0)
    80005756:	e3042b83          	lw	s7,-464(s0)
  for(i = 0; i < sz; i += PGSIZE){
    8000575a:	f60b8ae3          	beqz	s7,800056ce <exec+0x312>
    8000575e:	89de                	mv	s3,s7
    80005760:	4481                	li	s1,0
    80005762:	b371                	j	800054ee <exec+0x132>

0000000080005764 <argfd>:

// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
{
    80005764:	7179                	addi	sp,sp,-48
    80005766:	f406                	sd	ra,40(sp)
    80005768:	f022                	sd	s0,32(sp)
    8000576a:	ec26                	sd	s1,24(sp)
    8000576c:	e84a                	sd	s2,16(sp)
    8000576e:	1800                	addi	s0,sp,48
    80005770:	892e                	mv	s2,a1
    80005772:	84b2                	mv	s1,a2
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
    80005774:	fdc40593          	addi	a1,s0,-36
    80005778:	ffffd097          	auipc	ra,0xffffd
    8000577c:	2f2080e7          	jalr	754(ra) # 80002a6a <argint>
    80005780:	04054063          	bltz	a0,800057c0 <argfd+0x5c>
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
    80005784:	fdc42703          	lw	a4,-36(s0)
    80005788:	47bd                	li	a5,15
    8000578a:	02e7ed63          	bltu	a5,a4,800057c4 <argfd+0x60>
    8000578e:	ffffc097          	auipc	ra,0xffffc
    80005792:	21c080e7          	jalr	540(ra) # 800019aa <myproc>
    80005796:	fdc42703          	lw	a4,-36(s0)
    8000579a:	01a70793          	addi	a5,a4,26 # fffffffffffff01a <end+0xffffffff7ffde01a>
    8000579e:	078e                	slli	a5,a5,0x3
    800057a0:	953e                	add	a0,a0,a5
    800057a2:	611c                	ld	a5,0(a0)
    800057a4:	c395                	beqz	a5,800057c8 <argfd+0x64>
    return -1;
  if(pfd)
    800057a6:	00090463          	beqz	s2,800057ae <argfd+0x4a>
    *pfd = fd;
    800057aa:	00e92023          	sw	a4,0(s2)
  if(pf)
    *pf = f;
  return 0;
    800057ae:	4501                	li	a0,0
  if(pf)
    800057b0:	c091                	beqz	s1,800057b4 <argfd+0x50>
    *pf = f;
    800057b2:	e09c                	sd	a5,0(s1)
}
    800057b4:	70a2                	ld	ra,40(sp)
    800057b6:	7402                	ld	s0,32(sp)
    800057b8:	64e2                	ld	s1,24(sp)
    800057ba:	6942                	ld	s2,16(sp)
    800057bc:	6145                	addi	sp,sp,48
    800057be:	8082                	ret
    return -1;
    800057c0:	557d                	li	a0,-1
    800057c2:	bfcd                	j	800057b4 <argfd+0x50>
    return -1;
    800057c4:	557d                	li	a0,-1
    800057c6:	b7fd                	j	800057b4 <argfd+0x50>
    800057c8:	557d                	li	a0,-1
    800057ca:	b7ed                	j	800057b4 <argfd+0x50>

00000000800057cc <fdalloc>:

// Allocate a file descriptor for the given file.
// Takes over file reference from caller on success.
static int
fdalloc(struct file *f)
{
    800057cc:	1101                	addi	sp,sp,-32
    800057ce:	ec06                	sd	ra,24(sp)
    800057d0:	e822                	sd	s0,16(sp)
    800057d2:	e426                	sd	s1,8(sp)
    800057d4:	1000                	addi	s0,sp,32
    800057d6:	84aa                	mv	s1,a0
  int fd;
  struct proc *p = myproc();
    800057d8:	ffffc097          	auipc	ra,0xffffc
    800057dc:	1d2080e7          	jalr	466(ra) # 800019aa <myproc>
    800057e0:	862a                	mv	a2,a0

  for(fd = 0; fd < NOFILE; fd++){
    800057e2:	0d050793          	addi	a5,a0,208
    800057e6:	4501                	li	a0,0
    800057e8:	46c1                	li	a3,16
    if(p->ofile[fd] == 0){
    800057ea:	6398                	ld	a4,0(a5)
    800057ec:	cb19                	beqz	a4,80005802 <fdalloc+0x36>
  for(fd = 0; fd < NOFILE; fd++){
    800057ee:	2505                	addiw	a0,a0,1
    800057f0:	07a1                	addi	a5,a5,8
    800057f2:	fed51ce3          	bne	a0,a3,800057ea <fdalloc+0x1e>
      p->ofile[fd] = f;
      return fd;
    }
  }
  return -1;
    800057f6:	557d                	li	a0,-1
}
    800057f8:	60e2                	ld	ra,24(sp)
    800057fa:	6442                	ld	s0,16(sp)
    800057fc:	64a2                	ld	s1,8(sp)
    800057fe:	6105                	addi	sp,sp,32
    80005800:	8082                	ret
      p->ofile[fd] = f;
    80005802:	01a50793          	addi	a5,a0,26
    80005806:	078e                	slli	a5,a5,0x3
    80005808:	963e                	add	a2,a2,a5
    8000580a:	e204                	sd	s1,0(a2)
      return fd;
    8000580c:	b7f5                	j	800057f8 <fdalloc+0x2c>

000000008000580e <create>:
  return -1;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
    8000580e:	715d                	addi	sp,sp,-80
    80005810:	e486                	sd	ra,72(sp)
    80005812:	e0a2                	sd	s0,64(sp)
    80005814:	fc26                	sd	s1,56(sp)
    80005816:	f84a                	sd	s2,48(sp)
    80005818:	f44e                	sd	s3,40(sp)
    8000581a:	f052                	sd	s4,32(sp)
    8000581c:	ec56                	sd	s5,24(sp)
    8000581e:	0880                	addi	s0,sp,80
    80005820:	89ae                	mv	s3,a1
    80005822:	8ab2                	mv	s5,a2
    80005824:	8a36                	mv	s4,a3
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
    80005826:	fb040593          	addi	a1,s0,-80
    8000582a:	fffff097          	auipc	ra,0xfffff
    8000582e:	e6c080e7          	jalr	-404(ra) # 80004696 <nameiparent>
    80005832:	892a                	mv	s2,a0
    80005834:	12050e63          	beqz	a0,80005970 <create+0x162>
    return 0;

  ilock(dp);
    80005838:	ffffe097          	auipc	ra,0xffffe
    8000583c:	e6c080e7          	jalr	-404(ra) # 800036a4 <ilock>

  if((ip = dirlookup(dp, name, 0)) != 0){
    80005840:	4601                	li	a2,0
    80005842:	fb040593          	addi	a1,s0,-80
    80005846:	854a                	mv	a0,s2
    80005848:	fffff097          	auipc	ra,0xfffff
    8000584c:	af6080e7          	jalr	-1290(ra) # 8000433e <dirlookup>
    80005850:	84aa                	mv	s1,a0
    80005852:	c921                	beqz	a0,800058a2 <create+0x94>
    iunlockput(dp);
    80005854:	854a                	mv	a0,s2
    80005856:	ffffe097          	auipc	ra,0xffffe
    8000585a:	156080e7          	jalr	342(ra) # 800039ac <iunlockput>
    ilock(ip);
    8000585e:	8526                	mv	a0,s1
    80005860:	ffffe097          	auipc	ra,0xffffe
    80005864:	e44080e7          	jalr	-444(ra) # 800036a4 <ilock>
    if(type == T_FILE && (ip->type == T_FILE || ip->type == T_DEVICE))
    80005868:	2981                	sext.w	s3,s3
    8000586a:	4789                	li	a5,2
    8000586c:	02f99463          	bne	s3,a5,80005894 <create+0x86>
    80005870:	0444d783          	lhu	a5,68(s1)
    80005874:	37f9                	addiw	a5,a5,-2
    80005876:	17c2                	slli	a5,a5,0x30
    80005878:	93c1                	srli	a5,a5,0x30
    8000587a:	4705                	li	a4,1
    8000587c:	00f76c63          	bltu	a4,a5,80005894 <create+0x86>
    panic("create: dirlink");

  iunlockput(dp);

  return ip;
}
    80005880:	8526                	mv	a0,s1
    80005882:	60a6                	ld	ra,72(sp)
    80005884:	6406                	ld	s0,64(sp)
    80005886:	74e2                	ld	s1,56(sp)
    80005888:	7942                	ld	s2,48(sp)
    8000588a:	79a2                	ld	s3,40(sp)
    8000588c:	7a02                	ld	s4,32(sp)
    8000588e:	6ae2                	ld	s5,24(sp)
    80005890:	6161                	addi	sp,sp,80
    80005892:	8082                	ret
    iunlockput(ip);
    80005894:	8526                	mv	a0,s1
    80005896:	ffffe097          	auipc	ra,0xffffe
    8000589a:	116080e7          	jalr	278(ra) # 800039ac <iunlockput>
    return 0;
    8000589e:	4481                	li	s1,0
    800058a0:	b7c5                	j	80005880 <create+0x72>
  if((ip = ialloc(dp->dev, type)) == 0)
    800058a2:	85ce                	mv	a1,s3
    800058a4:	00092503          	lw	a0,0(s2)
    800058a8:	ffffe097          	auipc	ra,0xffffe
    800058ac:	c62080e7          	jalr	-926(ra) # 8000350a <ialloc>
    800058b0:	84aa                	mv	s1,a0
    800058b2:	c521                	beqz	a0,800058fa <create+0xec>
  ilock(ip);
    800058b4:	ffffe097          	auipc	ra,0xffffe
    800058b8:	df0080e7          	jalr	-528(ra) # 800036a4 <ilock>
  ip->major = major;
    800058bc:	05549323          	sh	s5,70(s1)
  ip->minor = minor;
    800058c0:	05449423          	sh	s4,72(s1)
  ip->nlink = 1;
    800058c4:	4a05                	li	s4,1
    800058c6:	05449523          	sh	s4,74(s1)
  iupdate(ip);
    800058ca:	8526                	mv	a0,s1
    800058cc:	ffffe097          	auipc	ra,0xffffe
    800058d0:	d0c080e7          	jalr	-756(ra) # 800035d8 <iupdate>
  if(type == T_DIR){  // Create . and .. entries.
    800058d4:	2981                	sext.w	s3,s3
    800058d6:	03498a63          	beq	s3,s4,8000590a <create+0xfc>
  if(dirlink(dp, name, ip->inum) < 0)
    800058da:	40d0                	lw	a2,4(s1)
    800058dc:	fb040593          	addi	a1,s0,-80
    800058e0:	854a                	mv	a0,s2
    800058e2:	fffff097          	auipc	ra,0xfffff
    800058e6:	cea080e7          	jalr	-790(ra) # 800045cc <dirlink>
    800058ea:	06054b63          	bltz	a0,80005960 <create+0x152>
  iunlockput(dp);
    800058ee:	854a                	mv	a0,s2
    800058f0:	ffffe097          	auipc	ra,0xffffe
    800058f4:	0bc080e7          	jalr	188(ra) # 800039ac <iunlockput>
  return ip;
    800058f8:	b761                	j	80005880 <create+0x72>
    panic("create: ialloc");
    800058fa:	00003517          	auipc	a0,0x3
    800058fe:	d9e50513          	addi	a0,a0,-610 # 80008698 <syscalls+0x278>
    80005902:	ffffb097          	auipc	ra,0xffffb
    80005906:	c2a080e7          	jalr	-982(ra) # 8000052c <panic>
    dp->nlink++;  // for ".."
    8000590a:	04a95783          	lhu	a5,74(s2)
    8000590e:	2785                	addiw	a5,a5,1
    80005910:	04f91523          	sh	a5,74(s2)
    iupdate(dp);
    80005914:	854a                	mv	a0,s2
    80005916:	ffffe097          	auipc	ra,0xffffe
    8000591a:	cc2080e7          	jalr	-830(ra) # 800035d8 <iupdate>
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
    8000591e:	40d0                	lw	a2,4(s1)
    80005920:	00003597          	auipc	a1,0x3
    80005924:	d8858593          	addi	a1,a1,-632 # 800086a8 <syscalls+0x288>
    80005928:	8526                	mv	a0,s1
    8000592a:	fffff097          	auipc	ra,0xfffff
    8000592e:	ca2080e7          	jalr	-862(ra) # 800045cc <dirlink>
    80005932:	00054f63          	bltz	a0,80005950 <create+0x142>
    80005936:	00492603          	lw	a2,4(s2)
    8000593a:	00003597          	auipc	a1,0x3
    8000593e:	d7658593          	addi	a1,a1,-650 # 800086b0 <syscalls+0x290>
    80005942:	8526                	mv	a0,s1
    80005944:	fffff097          	auipc	ra,0xfffff
    80005948:	c88080e7          	jalr	-888(ra) # 800045cc <dirlink>
    8000594c:	f80557e3          	bgez	a0,800058da <create+0xcc>
      panic("create dots");
    80005950:	00003517          	auipc	a0,0x3
    80005954:	d6850513          	addi	a0,a0,-664 # 800086b8 <syscalls+0x298>
    80005958:	ffffb097          	auipc	ra,0xffffb
    8000595c:	bd4080e7          	jalr	-1068(ra) # 8000052c <panic>
    panic("create: dirlink");
    80005960:	00003517          	auipc	a0,0x3
    80005964:	d6850513          	addi	a0,a0,-664 # 800086c8 <syscalls+0x2a8>
    80005968:	ffffb097          	auipc	ra,0xffffb
    8000596c:	bc4080e7          	jalr	-1084(ra) # 8000052c <panic>
    return 0;
    80005970:	84aa                	mv	s1,a0
    80005972:	b739                	j	80005880 <create+0x72>

0000000080005974 <sys_dup>:
{
    80005974:	7179                	addi	sp,sp,-48
    80005976:	f406                	sd	ra,40(sp)
    80005978:	f022                	sd	s0,32(sp)
    8000597a:	ec26                	sd	s1,24(sp)
    8000597c:	e84a                	sd	s2,16(sp)
    8000597e:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0)
    80005980:	fd840613          	addi	a2,s0,-40
    80005984:	4581                	li	a1,0
    80005986:	4501                	li	a0,0
    80005988:	00000097          	auipc	ra,0x0
    8000598c:	ddc080e7          	jalr	-548(ra) # 80005764 <argfd>
    return -1;
    80005990:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0)
    80005992:	02054363          	bltz	a0,800059b8 <sys_dup+0x44>
  if((fd=fdalloc(f)) < 0)
    80005996:	fd843903          	ld	s2,-40(s0)
    8000599a:	854a                	mv	a0,s2
    8000599c:	00000097          	auipc	ra,0x0
    800059a0:	e30080e7          	jalr	-464(ra) # 800057cc <fdalloc>
    800059a4:	84aa                	mv	s1,a0
    return -1;
    800059a6:	57fd                	li	a5,-1
  if((fd=fdalloc(f)) < 0)
    800059a8:	00054863          	bltz	a0,800059b8 <sys_dup+0x44>
  filedup(f);
    800059ac:	854a                	mv	a0,s2
    800059ae:	fffff097          	auipc	ra,0xfffff
    800059b2:	368080e7          	jalr	872(ra) # 80004d16 <filedup>
  return fd;
    800059b6:	87a6                	mv	a5,s1
}
    800059b8:	853e                	mv	a0,a5
    800059ba:	70a2                	ld	ra,40(sp)
    800059bc:	7402                	ld	s0,32(sp)
    800059be:	64e2                	ld	s1,24(sp)
    800059c0:	6942                	ld	s2,16(sp)
    800059c2:	6145                	addi	sp,sp,48
    800059c4:	8082                	ret

00000000800059c6 <sys_read>:
{
    800059c6:	7179                	addi	sp,sp,-48
    800059c8:	f406                	sd	ra,40(sp)
    800059ca:	f022                	sd	s0,32(sp)
    800059cc:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800059ce:	fe840613          	addi	a2,s0,-24
    800059d2:	4581                	li	a1,0
    800059d4:	4501                	li	a0,0
    800059d6:	00000097          	auipc	ra,0x0
    800059da:	d8e080e7          	jalr	-626(ra) # 80005764 <argfd>
    return -1;
    800059de:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800059e0:	04054163          	bltz	a0,80005a22 <sys_read+0x5c>
    800059e4:	fe440593          	addi	a1,s0,-28
    800059e8:	4509                	li	a0,2
    800059ea:	ffffd097          	auipc	ra,0xffffd
    800059ee:	080080e7          	jalr	128(ra) # 80002a6a <argint>
    return -1;
    800059f2:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800059f4:	02054763          	bltz	a0,80005a22 <sys_read+0x5c>
    800059f8:	fd840593          	addi	a1,s0,-40
    800059fc:	4505                	li	a0,1
    800059fe:	ffffd097          	auipc	ra,0xffffd
    80005a02:	08e080e7          	jalr	142(ra) # 80002a8c <argaddr>
    return -1;
    80005a06:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005a08:	00054d63          	bltz	a0,80005a22 <sys_read+0x5c>
  return fileread(f, p, n);
    80005a0c:	fe442603          	lw	a2,-28(s0)
    80005a10:	fd843583          	ld	a1,-40(s0)
    80005a14:	fe843503          	ld	a0,-24(s0)
    80005a18:	fffff097          	auipc	ra,0xfffff
    80005a1c:	48a080e7          	jalr	1162(ra) # 80004ea2 <fileread>
    80005a20:	87aa                	mv	a5,a0
}
    80005a22:	853e                	mv	a0,a5
    80005a24:	70a2                	ld	ra,40(sp)
    80005a26:	7402                	ld	s0,32(sp)
    80005a28:	6145                	addi	sp,sp,48
    80005a2a:	8082                	ret

0000000080005a2c <sys_write>:
{
    80005a2c:	7179                	addi	sp,sp,-48
    80005a2e:	f406                	sd	ra,40(sp)
    80005a30:	f022                	sd	s0,32(sp)
    80005a32:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005a34:	fe840613          	addi	a2,s0,-24
    80005a38:	4581                	li	a1,0
    80005a3a:	4501                	li	a0,0
    80005a3c:	00000097          	auipc	ra,0x0
    80005a40:	d28080e7          	jalr	-728(ra) # 80005764 <argfd>
    return -1;
    80005a44:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005a46:	04054163          	bltz	a0,80005a88 <sys_write+0x5c>
    80005a4a:	fe440593          	addi	a1,s0,-28
    80005a4e:	4509                	li	a0,2
    80005a50:	ffffd097          	auipc	ra,0xffffd
    80005a54:	01a080e7          	jalr	26(ra) # 80002a6a <argint>
    return -1;
    80005a58:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005a5a:	02054763          	bltz	a0,80005a88 <sys_write+0x5c>
    80005a5e:	fd840593          	addi	a1,s0,-40
    80005a62:	4505                	li	a0,1
    80005a64:	ffffd097          	auipc	ra,0xffffd
    80005a68:	028080e7          	jalr	40(ra) # 80002a8c <argaddr>
    return -1;
    80005a6c:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005a6e:	00054d63          	bltz	a0,80005a88 <sys_write+0x5c>
  return filewrite(f, p, n);
    80005a72:	fe442603          	lw	a2,-28(s0)
    80005a76:	fd843583          	ld	a1,-40(s0)
    80005a7a:	fe843503          	ld	a0,-24(s0)
    80005a7e:	fffff097          	auipc	ra,0xfffff
    80005a82:	4e6080e7          	jalr	1254(ra) # 80004f64 <filewrite>
    80005a86:	87aa                	mv	a5,a0
}
    80005a88:	853e                	mv	a0,a5
    80005a8a:	70a2                	ld	ra,40(sp)
    80005a8c:	7402                	ld	s0,32(sp)
    80005a8e:	6145                	addi	sp,sp,48
    80005a90:	8082                	ret

0000000080005a92 <sys_rbtn>:
{
    80005a92:	7179                	addi	sp,sp,-48
    80005a94:	f406                	sd	ra,40(sp)
    80005a96:	f022                	sd	s0,32(sp)
    80005a98:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    80005a9a:	fe840613          	addi	a2,s0,-24
    80005a9e:	4581                	li	a1,0
    80005aa0:	4501                	li	a0,0
    80005aa2:	00000097          	auipc	ra,0x0
    80005aa6:	cc2080e7          	jalr	-830(ra) # 80005764 <argfd>
    return -1;
    80005aaa:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    80005aac:	04054f63          	bltz	a0,80005b0a <sys_rbtn+0x78>
    80005ab0:	fe440593          	addi	a1,s0,-28
    80005ab4:	4509                	li	a0,2
    80005ab6:	ffffd097          	auipc	ra,0xffffd
    80005aba:	fb4080e7          	jalr	-76(ra) # 80002a6a <argint>
    return -1;
    80005abe:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    80005ac0:	04054563          	bltz	a0,80005b0a <sys_rbtn+0x78>
    80005ac4:	fe040593          	addi	a1,s0,-32
    80005ac8:	450d                	li	a0,3
    80005aca:	ffffd097          	auipc	ra,0xffffd
    80005ace:	fa0080e7          	jalr	-96(ra) # 80002a6a <argint>
    return -1;
    80005ad2:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    80005ad4:	02054b63          	bltz	a0,80005b0a <sys_rbtn+0x78>
    80005ad8:	fd840593          	addi	a1,s0,-40
    80005adc:	4505                	li	a0,1
    80005ade:	ffffd097          	auipc	ra,0xffffd
    80005ae2:	fae080e7          	jalr	-82(ra) # 80002a8c <argaddr>
    return -1;
    80005ae6:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argint(3, &block) < 0 || argaddr(1, &p) < 0)
    80005ae8:	02054163          	bltz	a0,80005b0a <sys_rbtn+0x78>
  return rbtn(f->ip, 1, p, n, block);
    80005aec:	fe042703          	lw	a4,-32(s0)
    80005af0:	fe442683          	lw	a3,-28(s0)
    80005af4:	fd843603          	ld	a2,-40(s0)
    80005af8:	4585                	li	a1,1
    80005afa:	fe843783          	ld	a5,-24(s0)
    80005afe:	6f88                	ld	a0,24(a5)
    80005b00:	ffffe097          	auipc	ra,0xffffe
    80005b04:	130080e7          	jalr	304(ra) # 80003c30 <rbtn>
    80005b08:	87aa                	mv	a5,a0
}
    80005b0a:	853e                	mv	a0,a5
    80005b0c:	70a2                	ld	ra,40(sp)
    80005b0e:	7402                	ld	s0,32(sp)
    80005b10:	6145                	addi	sp,sp,48
    80005b12:	8082                	ret

0000000080005b14 <sys_close>:
{
    80005b14:	1101                	addi	sp,sp,-32
    80005b16:	ec06                	sd	ra,24(sp)
    80005b18:	e822                	sd	s0,16(sp)
    80005b1a:	1000                	addi	s0,sp,32
  if(argfd(0, &fd, &f) < 0)
    80005b1c:	fe040613          	addi	a2,s0,-32
    80005b20:	fec40593          	addi	a1,s0,-20
    80005b24:	4501                	li	a0,0
    80005b26:	00000097          	auipc	ra,0x0
    80005b2a:	c3e080e7          	jalr	-962(ra) # 80005764 <argfd>
    return -1;
    80005b2e:	57fd                	li	a5,-1
  if(argfd(0, &fd, &f) < 0)
    80005b30:	02054463          	bltz	a0,80005b58 <sys_close+0x44>
  myproc()->ofile[fd] = 0;
    80005b34:	ffffc097          	auipc	ra,0xffffc
    80005b38:	e76080e7          	jalr	-394(ra) # 800019aa <myproc>
    80005b3c:	fec42783          	lw	a5,-20(s0)
    80005b40:	07e9                	addi	a5,a5,26
    80005b42:	078e                	slli	a5,a5,0x3
    80005b44:	953e                	add	a0,a0,a5
    80005b46:	00053023          	sd	zero,0(a0)
  fileclose(f);
    80005b4a:	fe043503          	ld	a0,-32(s0)
    80005b4e:	fffff097          	auipc	ra,0xfffff
    80005b52:	21a080e7          	jalr	538(ra) # 80004d68 <fileclose>
  return 0;
    80005b56:	4781                	li	a5,0
}
    80005b58:	853e                	mv	a0,a5
    80005b5a:	60e2                	ld	ra,24(sp)
    80005b5c:	6442                	ld	s0,16(sp)
    80005b5e:	6105                	addi	sp,sp,32
    80005b60:	8082                	ret

0000000080005b62 <sys_fstat>:
{
    80005b62:	1101                	addi	sp,sp,-32
    80005b64:	ec06                	sd	ra,24(sp)
    80005b66:	e822                	sd	s0,16(sp)
    80005b68:	1000                	addi	s0,sp,32
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005b6a:	fe840613          	addi	a2,s0,-24
    80005b6e:	4581                	li	a1,0
    80005b70:	4501                	li	a0,0
    80005b72:	00000097          	auipc	ra,0x0
    80005b76:	bf2080e7          	jalr	-1038(ra) # 80005764 <argfd>
    return -1;
    80005b7a:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005b7c:	02054563          	bltz	a0,80005ba6 <sys_fstat+0x44>
    80005b80:	fe040593          	addi	a1,s0,-32
    80005b84:	4505                	li	a0,1
    80005b86:	ffffd097          	auipc	ra,0xffffd
    80005b8a:	f06080e7          	jalr	-250(ra) # 80002a8c <argaddr>
    return -1;
    80005b8e:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005b90:	00054b63          	bltz	a0,80005ba6 <sys_fstat+0x44>
  return filestat(f, st);
    80005b94:	fe043583          	ld	a1,-32(s0)
    80005b98:	fe843503          	ld	a0,-24(s0)
    80005b9c:	fffff097          	auipc	ra,0xfffff
    80005ba0:	294080e7          	jalr	660(ra) # 80004e30 <filestat>
    80005ba4:	87aa                	mv	a5,a0
}
    80005ba6:	853e                	mv	a0,a5
    80005ba8:	60e2                	ld	ra,24(sp)
    80005baa:	6442                	ld	s0,16(sp)
    80005bac:	6105                	addi	sp,sp,32
    80005bae:	8082                	ret

0000000080005bb0 <sys_link>:
{
    80005bb0:	7169                	addi	sp,sp,-304
    80005bb2:	f606                	sd	ra,296(sp)
    80005bb4:	f222                	sd	s0,288(sp)
    80005bb6:	ee26                	sd	s1,280(sp)
    80005bb8:	ea4a                	sd	s2,272(sp)
    80005bba:	1a00                	addi	s0,sp,304
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005bbc:	08000613          	li	a2,128
    80005bc0:	ed040593          	addi	a1,s0,-304
    80005bc4:	4501                	li	a0,0
    80005bc6:	ffffd097          	auipc	ra,0xffffd
    80005bca:	ee8080e7          	jalr	-280(ra) # 80002aae <argstr>
    return -1;
    80005bce:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005bd0:	10054e63          	bltz	a0,80005cec <sys_link+0x13c>
    80005bd4:	08000613          	li	a2,128
    80005bd8:	f5040593          	addi	a1,s0,-176
    80005bdc:	4505                	li	a0,1
    80005bde:	ffffd097          	auipc	ra,0xffffd
    80005be2:	ed0080e7          	jalr	-304(ra) # 80002aae <argstr>
    return -1;
    80005be6:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005be8:	10054263          	bltz	a0,80005cec <sys_link+0x13c>
  begin_op();
    80005bec:	fffff097          	auipc	ra,0xfffff
    80005bf0:	cac080e7          	jalr	-852(ra) # 80004898 <begin_op>
  if((ip = namei(old)) == 0){
    80005bf4:	ed040513          	addi	a0,s0,-304
    80005bf8:	fffff097          	auipc	ra,0xfffff
    80005bfc:	a80080e7          	jalr	-1408(ra) # 80004678 <namei>
    80005c00:	84aa                	mv	s1,a0
    80005c02:	c551                	beqz	a0,80005c8e <sys_link+0xde>
  ilock(ip);
    80005c04:	ffffe097          	auipc	ra,0xffffe
    80005c08:	aa0080e7          	jalr	-1376(ra) # 800036a4 <ilock>
  if(ip->type == T_DIR){
    80005c0c:	04449703          	lh	a4,68(s1)
    80005c10:	4785                	li	a5,1
    80005c12:	08f70463          	beq	a4,a5,80005c9a <sys_link+0xea>
  ip->nlink++;
    80005c16:	04a4d783          	lhu	a5,74(s1)
    80005c1a:	2785                	addiw	a5,a5,1
    80005c1c:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    80005c20:	8526                	mv	a0,s1
    80005c22:	ffffe097          	auipc	ra,0xffffe
    80005c26:	9b6080e7          	jalr	-1610(ra) # 800035d8 <iupdate>
  iunlock(ip);
    80005c2a:	8526                	mv	a0,s1
    80005c2c:	ffffe097          	auipc	ra,0xffffe
    80005c30:	b3a080e7          	jalr	-1222(ra) # 80003766 <iunlock>
  if((dp = nameiparent(new, name)) == 0)
    80005c34:	fd040593          	addi	a1,s0,-48
    80005c38:	f5040513          	addi	a0,s0,-176
    80005c3c:	fffff097          	auipc	ra,0xfffff
    80005c40:	a5a080e7          	jalr	-1446(ra) # 80004696 <nameiparent>
    80005c44:	892a                	mv	s2,a0
    80005c46:	c935                	beqz	a0,80005cba <sys_link+0x10a>
  ilock(dp);
    80005c48:	ffffe097          	auipc	ra,0xffffe
    80005c4c:	a5c080e7          	jalr	-1444(ra) # 800036a4 <ilock>
  if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
    80005c50:	00092703          	lw	a4,0(s2)
    80005c54:	409c                	lw	a5,0(s1)
    80005c56:	04f71d63          	bne	a4,a5,80005cb0 <sys_link+0x100>
    80005c5a:	40d0                	lw	a2,4(s1)
    80005c5c:	fd040593          	addi	a1,s0,-48
    80005c60:	854a                	mv	a0,s2
    80005c62:	fffff097          	auipc	ra,0xfffff
    80005c66:	96a080e7          	jalr	-1686(ra) # 800045cc <dirlink>
    80005c6a:	04054363          	bltz	a0,80005cb0 <sys_link+0x100>
  iunlockput(dp);
    80005c6e:	854a                	mv	a0,s2
    80005c70:	ffffe097          	auipc	ra,0xffffe
    80005c74:	d3c080e7          	jalr	-708(ra) # 800039ac <iunlockput>
  iput(ip);
    80005c78:	8526                	mv	a0,s1
    80005c7a:	ffffe097          	auipc	ra,0xffffe
    80005c7e:	c8a080e7          	jalr	-886(ra) # 80003904 <iput>
  end_op();
    80005c82:	fffff097          	auipc	ra,0xfffff
    80005c86:	c94080e7          	jalr	-876(ra) # 80004916 <end_op>
  return 0;
    80005c8a:	4781                	li	a5,0
    80005c8c:	a085                	j	80005cec <sys_link+0x13c>
    end_op();
    80005c8e:	fffff097          	auipc	ra,0xfffff
    80005c92:	c88080e7          	jalr	-888(ra) # 80004916 <end_op>
    return -1;
    80005c96:	57fd                	li	a5,-1
    80005c98:	a891                	j	80005cec <sys_link+0x13c>
    iunlockput(ip);
    80005c9a:	8526                	mv	a0,s1
    80005c9c:	ffffe097          	auipc	ra,0xffffe
    80005ca0:	d10080e7          	jalr	-752(ra) # 800039ac <iunlockput>
    end_op();
    80005ca4:	fffff097          	auipc	ra,0xfffff
    80005ca8:	c72080e7          	jalr	-910(ra) # 80004916 <end_op>
    return -1;
    80005cac:	57fd                	li	a5,-1
    80005cae:	a83d                	j	80005cec <sys_link+0x13c>
    iunlockput(dp);
    80005cb0:	854a                	mv	a0,s2
    80005cb2:	ffffe097          	auipc	ra,0xffffe
    80005cb6:	cfa080e7          	jalr	-774(ra) # 800039ac <iunlockput>
  ilock(ip);
    80005cba:	8526                	mv	a0,s1
    80005cbc:	ffffe097          	auipc	ra,0xffffe
    80005cc0:	9e8080e7          	jalr	-1560(ra) # 800036a4 <ilock>
  ip->nlink--;
    80005cc4:	04a4d783          	lhu	a5,74(s1)
    80005cc8:	37fd                	addiw	a5,a5,-1
    80005cca:	04f49523          	sh	a5,74(s1)
  iupdate(ip);
    80005cce:	8526                	mv	a0,s1
    80005cd0:	ffffe097          	auipc	ra,0xffffe
    80005cd4:	908080e7          	jalr	-1784(ra) # 800035d8 <iupdate>
  iunlockput(ip);
    80005cd8:	8526                	mv	a0,s1
    80005cda:	ffffe097          	auipc	ra,0xffffe
    80005cde:	cd2080e7          	jalr	-814(ra) # 800039ac <iunlockput>
  end_op();
    80005ce2:	fffff097          	auipc	ra,0xfffff
    80005ce6:	c34080e7          	jalr	-972(ra) # 80004916 <end_op>
  return -1;
    80005cea:	57fd                	li	a5,-1
}
    80005cec:	853e                	mv	a0,a5
    80005cee:	70b2                	ld	ra,296(sp)
    80005cf0:	7412                	ld	s0,288(sp)
    80005cf2:	64f2                	ld	s1,280(sp)
    80005cf4:	6952                	ld	s2,272(sp)
    80005cf6:	6155                	addi	sp,sp,304
    80005cf8:	8082                	ret

0000000080005cfa <sys_unlink>:
{
    80005cfa:	7151                	addi	sp,sp,-240
    80005cfc:	f586                	sd	ra,232(sp)
    80005cfe:	f1a2                	sd	s0,224(sp)
    80005d00:	eda6                	sd	s1,216(sp)
    80005d02:	e9ca                	sd	s2,208(sp)
    80005d04:	e5ce                	sd	s3,200(sp)
    80005d06:	1980                	addi	s0,sp,240
  if(argstr(0, path, MAXPATH) < 0)
    80005d08:	08000613          	li	a2,128
    80005d0c:	f3040593          	addi	a1,s0,-208
    80005d10:	4501                	li	a0,0
    80005d12:	ffffd097          	auipc	ra,0xffffd
    80005d16:	d9c080e7          	jalr	-612(ra) # 80002aae <argstr>
    80005d1a:	18054163          	bltz	a0,80005e9c <sys_unlink+0x1a2>
  begin_op();
    80005d1e:	fffff097          	auipc	ra,0xfffff
    80005d22:	b7a080e7          	jalr	-1158(ra) # 80004898 <begin_op>
  if((dp = nameiparent(path, name)) == 0){
    80005d26:	fb040593          	addi	a1,s0,-80
    80005d2a:	f3040513          	addi	a0,s0,-208
    80005d2e:	fffff097          	auipc	ra,0xfffff
    80005d32:	968080e7          	jalr	-1688(ra) # 80004696 <nameiparent>
    80005d36:	84aa                	mv	s1,a0
    80005d38:	c979                	beqz	a0,80005e0e <sys_unlink+0x114>
  ilock(dp);
    80005d3a:	ffffe097          	auipc	ra,0xffffe
    80005d3e:	96a080e7          	jalr	-1686(ra) # 800036a4 <ilock>
  if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
    80005d42:	00003597          	auipc	a1,0x3
    80005d46:	96658593          	addi	a1,a1,-1690 # 800086a8 <syscalls+0x288>
    80005d4a:	fb040513          	addi	a0,s0,-80
    80005d4e:	ffffe097          	auipc	ra,0xffffe
    80005d52:	ec8080e7          	jalr	-312(ra) # 80003c16 <namecmp>
    80005d56:	14050a63          	beqz	a0,80005eaa <sys_unlink+0x1b0>
    80005d5a:	00003597          	auipc	a1,0x3
    80005d5e:	95658593          	addi	a1,a1,-1706 # 800086b0 <syscalls+0x290>
    80005d62:	fb040513          	addi	a0,s0,-80
    80005d66:	ffffe097          	auipc	ra,0xffffe
    80005d6a:	eb0080e7          	jalr	-336(ra) # 80003c16 <namecmp>
    80005d6e:	12050e63          	beqz	a0,80005eaa <sys_unlink+0x1b0>
  if((ip = dirlookup(dp, name, &off)) == 0)
    80005d72:	f2c40613          	addi	a2,s0,-212
    80005d76:	fb040593          	addi	a1,s0,-80
    80005d7a:	8526                	mv	a0,s1
    80005d7c:	ffffe097          	auipc	ra,0xffffe
    80005d80:	5c2080e7          	jalr	1474(ra) # 8000433e <dirlookup>
    80005d84:	892a                	mv	s2,a0
    80005d86:	12050263          	beqz	a0,80005eaa <sys_unlink+0x1b0>
  ilock(ip);
    80005d8a:	ffffe097          	auipc	ra,0xffffe
    80005d8e:	91a080e7          	jalr	-1766(ra) # 800036a4 <ilock>
  if(ip->nlink < 1)
    80005d92:	04a91783          	lh	a5,74(s2)
    80005d96:	08f05263          	blez	a5,80005e1a <sys_unlink+0x120>
  if(ip->type == T_DIR && !isdirempty(ip)){
    80005d9a:	04491703          	lh	a4,68(s2)
    80005d9e:	4785                	li	a5,1
    80005da0:	08f70563          	beq	a4,a5,80005e2a <sys_unlink+0x130>
  memset(&de, 0, sizeof(de));
    80005da4:	4641                	li	a2,16
    80005da6:	4581                	li	a1,0
    80005da8:	fc040513          	addi	a0,s0,-64
    80005dac:	ffffb097          	auipc	ra,0xffffb
    80005db0:	f12080e7          	jalr	-238(ra) # 80000cbe <memset>
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80005db4:	4741                	li	a4,16
    80005db6:	f2c42683          	lw	a3,-212(s0)
    80005dba:	fc040613          	addi	a2,s0,-64
    80005dbe:	4581                	li	a1,0
    80005dc0:	8526                	mv	a0,s1
    80005dc2:	ffffe097          	auipc	ra,0xffffe
    80005dc6:	d34080e7          	jalr	-716(ra) # 80003af6 <writei>
    80005dca:	47c1                	li	a5,16
    80005dcc:	0af51563          	bne	a0,a5,80005e76 <sys_unlink+0x17c>
  if(ip->type == T_DIR){
    80005dd0:	04491703          	lh	a4,68(s2)
    80005dd4:	4785                	li	a5,1
    80005dd6:	0af70863          	beq	a4,a5,80005e86 <sys_unlink+0x18c>
  iunlockput(dp);
    80005dda:	8526                	mv	a0,s1
    80005ddc:	ffffe097          	auipc	ra,0xffffe
    80005de0:	bd0080e7          	jalr	-1072(ra) # 800039ac <iunlockput>
  ip->nlink--;
    80005de4:	04a95783          	lhu	a5,74(s2)
    80005de8:	37fd                	addiw	a5,a5,-1
    80005dea:	04f91523          	sh	a5,74(s2)
  iupdate(ip);
    80005dee:	854a                	mv	a0,s2
    80005df0:	ffffd097          	auipc	ra,0xffffd
    80005df4:	7e8080e7          	jalr	2024(ra) # 800035d8 <iupdate>
  iunlockput(ip);
    80005df8:	854a                	mv	a0,s2
    80005dfa:	ffffe097          	auipc	ra,0xffffe
    80005dfe:	bb2080e7          	jalr	-1102(ra) # 800039ac <iunlockput>
  end_op();
    80005e02:	fffff097          	auipc	ra,0xfffff
    80005e06:	b14080e7          	jalr	-1260(ra) # 80004916 <end_op>
  return 0;
    80005e0a:	4501                	li	a0,0
    80005e0c:	a84d                	j	80005ebe <sys_unlink+0x1c4>
    end_op();
    80005e0e:	fffff097          	auipc	ra,0xfffff
    80005e12:	b08080e7          	jalr	-1272(ra) # 80004916 <end_op>
    return -1;
    80005e16:	557d                	li	a0,-1
    80005e18:	a05d                	j	80005ebe <sys_unlink+0x1c4>
    panic("unlink: nlink < 1");
    80005e1a:	00003517          	auipc	a0,0x3
    80005e1e:	8be50513          	addi	a0,a0,-1858 # 800086d8 <syscalls+0x2b8>
    80005e22:	ffffa097          	auipc	ra,0xffffa
    80005e26:	70a080e7          	jalr	1802(ra) # 8000052c <panic>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005e2a:	04c92703          	lw	a4,76(s2)
    80005e2e:	02000793          	li	a5,32
    80005e32:	f6e7f9e3          	bgeu	a5,a4,80005da4 <sys_unlink+0xaa>
    80005e36:	02000993          	li	s3,32
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80005e3a:	4741                	li	a4,16
    80005e3c:	86ce                	mv	a3,s3
    80005e3e:	f1840613          	addi	a2,s0,-232
    80005e42:	4581                	li	a1,0
    80005e44:	854a                	mv	a0,s2
    80005e46:	ffffe097          	auipc	ra,0xffffe
    80005e4a:	bb8080e7          	jalr	-1096(ra) # 800039fe <readi>
    80005e4e:	47c1                	li	a5,16
    80005e50:	00f51b63          	bne	a0,a5,80005e66 <sys_unlink+0x16c>
    if(de.inum != 0)
    80005e54:	f1845783          	lhu	a5,-232(s0)
    80005e58:	e7a1                	bnez	a5,80005ea0 <sys_unlink+0x1a6>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005e5a:	29c1                	addiw	s3,s3,16
    80005e5c:	04c92783          	lw	a5,76(s2)
    80005e60:	fcf9ede3          	bltu	s3,a5,80005e3a <sys_unlink+0x140>
    80005e64:	b781                	j	80005da4 <sys_unlink+0xaa>
      panic("isdirempty: readi");
    80005e66:	00003517          	auipc	a0,0x3
    80005e6a:	88a50513          	addi	a0,a0,-1910 # 800086f0 <syscalls+0x2d0>
    80005e6e:	ffffa097          	auipc	ra,0xffffa
    80005e72:	6be080e7          	jalr	1726(ra) # 8000052c <panic>
    panic("unlink: writei");
    80005e76:	00003517          	auipc	a0,0x3
    80005e7a:	89250513          	addi	a0,a0,-1902 # 80008708 <syscalls+0x2e8>
    80005e7e:	ffffa097          	auipc	ra,0xffffa
    80005e82:	6ae080e7          	jalr	1710(ra) # 8000052c <panic>
    dp->nlink--;
    80005e86:	04a4d783          	lhu	a5,74(s1)
    80005e8a:	37fd                	addiw	a5,a5,-1
    80005e8c:	04f49523          	sh	a5,74(s1)
    iupdate(dp);
    80005e90:	8526                	mv	a0,s1
    80005e92:	ffffd097          	auipc	ra,0xffffd
    80005e96:	746080e7          	jalr	1862(ra) # 800035d8 <iupdate>
    80005e9a:	b781                	j	80005dda <sys_unlink+0xe0>
    return -1;
    80005e9c:	557d                	li	a0,-1
    80005e9e:	a005                	j	80005ebe <sys_unlink+0x1c4>
    iunlockput(ip);
    80005ea0:	854a                	mv	a0,s2
    80005ea2:	ffffe097          	auipc	ra,0xffffe
    80005ea6:	b0a080e7          	jalr	-1270(ra) # 800039ac <iunlockput>
  iunlockput(dp);
    80005eaa:	8526                	mv	a0,s1
    80005eac:	ffffe097          	auipc	ra,0xffffe
    80005eb0:	b00080e7          	jalr	-1280(ra) # 800039ac <iunlockput>
  end_op();
    80005eb4:	fffff097          	auipc	ra,0xfffff
    80005eb8:	a62080e7          	jalr	-1438(ra) # 80004916 <end_op>
  return -1;
    80005ebc:	557d                	li	a0,-1
}
    80005ebe:	70ae                	ld	ra,232(sp)
    80005ec0:	740e                	ld	s0,224(sp)
    80005ec2:	64ee                	ld	s1,216(sp)
    80005ec4:	694e                	ld	s2,208(sp)
    80005ec6:	69ae                	ld	s3,200(sp)
    80005ec8:	616d                	addi	sp,sp,240
    80005eca:	8082                	ret

0000000080005ecc <sys_symlink>:

uint64
sys_symlink(void)
{
    80005ecc:	712d                	addi	sp,sp,-288
    80005ece:	ee06                	sd	ra,280(sp)
    80005ed0:	ea22                	sd	s0,272(sp)
    80005ed2:	e626                	sd	s1,264(sp)
    80005ed4:	1200                	addi	s0,sp,288
  char new[MAXPATH], old[MAXPATH];
  struct inode *ip;

  // 获取参数值
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005ed6:	08000613          	li	a2,128
    80005eda:	ee040593          	addi	a1,s0,-288
    80005ede:	4501                	li	a0,0
    80005ee0:	ffffd097          	auipc	ra,0xffffd
    80005ee4:	bce080e7          	jalr	-1074(ra) # 80002aae <argstr>
    return -1;
    80005ee8:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005eea:	06054363          	bltz	a0,80005f50 <sys_symlink+0x84>
    80005eee:	08000613          	li	a2,128
    80005ef2:	f6040593          	addi	a1,s0,-160
    80005ef6:	4505                	li	a0,1
    80005ef8:	ffffd097          	auipc	ra,0xffffd
    80005efc:	bb6080e7          	jalr	-1098(ra) # 80002aae <argstr>
    return -1;
    80005f00:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005f02:	04054763          	bltz	a0,80005f50 <sys_symlink+0x84>
  // 创建软链接文件
  // 操作开始
  begin_op();
    80005f06:	fffff097          	auipc	ra,0xfffff
    80005f0a:	992080e7          	jalr	-1646(ra) # 80004898 <begin_op>
  // 根据new创建一个T_SYMLINK类型的文件，获取其inode
  ip = create(new, T_SYMLINK, 0, 0);
    80005f0e:	4681                	li	a3,0
    80005f10:	4601                	li	a2,0
    80005f12:	4591                	li	a1,4
    80005f14:	f6040513          	addi	a0,s0,-160
    80005f18:	00000097          	auipc	ra,0x0
    80005f1c:	8f6080e7          	jalr	-1802(ra) # 8000580e <create>
    80005f20:	84aa                	mv	s1,a0
  // 判断是否获取成功
  if(ip == 0){
    80005f22:	cd0d                	beqz	a0,80005f5c <sys_symlink+0x90>
    // 操作结束，失败返回
    goto bad;
  }
  // 将old写入获取的inode节点的第一个direct-mapped块中，判断是否写入成功
  if(writei(ip, 0, (uint64)old, 0, MAXPATH) < 0){
    80005f24:	08000713          	li	a4,128
    80005f28:	4681                	li	a3,0
    80005f2a:	ee040613          	addi	a2,s0,-288
    80005f2e:	4581                	li	a1,0
    80005f30:	ffffe097          	auipc	ra,0xffffe
    80005f34:	bc6080e7          	jalr	-1082(ra) # 80003af6 <writei>
    80005f38:	02054263          	bltz	a0,80005f5c <sys_symlink+0x90>
    // 操作结束，失败返回
    goto bad;
  }
  // 写入完成，将create中上的锁解除
  iunlockput(ip);
    80005f3c:	8526                	mv	a0,s1
    80005f3e:	ffffe097          	auipc	ra,0xffffe
    80005f42:	a6e080e7          	jalr	-1426(ra) # 800039ac <iunlockput>
  // 操作结束
  end_op();
    80005f46:	fffff097          	auipc	ra,0xfffff
    80005f4a:	9d0080e7          	jalr	-1584(ra) # 80004916 <end_op>
  return 0;
    80005f4e:	4781                	li	a5,0

bad:
  end_op();
  return -1;
}
    80005f50:	853e                	mv	a0,a5
    80005f52:	60f2                	ld	ra,280(sp)
    80005f54:	6452                	ld	s0,272(sp)
    80005f56:	64b2                	ld	s1,264(sp)
    80005f58:	6115                	addi	sp,sp,288
    80005f5a:	8082                	ret
  end_op();
    80005f5c:	fffff097          	auipc	ra,0xfffff
    80005f60:	9ba080e7          	jalr	-1606(ra) # 80004916 <end_op>
  return -1;
    80005f64:	57fd                	li	a5,-1
    80005f66:	b7ed                	j	80005f50 <sys_symlink+0x84>

0000000080005f68 <sys_open>:

uint64
sys_open(void)
{
    80005f68:	7131                	addi	sp,sp,-192
    80005f6a:	fd06                	sd	ra,184(sp)
    80005f6c:	f922                	sd	s0,176(sp)
    80005f6e:	f526                	sd	s1,168(sp)
    80005f70:	f14a                	sd	s2,160(sp)
    80005f72:	ed4e                	sd	s3,152(sp)
    80005f74:	0180                	addi	s0,sp,192
  int fd, omode;
  struct file *f;
  struct inode *ip;
  int n;

  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    80005f76:	08000613          	li	a2,128
    80005f7a:	f5040593          	addi	a1,s0,-176
    80005f7e:	4501                	li	a0,0
    80005f80:	ffffd097          	auipc	ra,0xffffd
    80005f84:	b2e080e7          	jalr	-1234(ra) # 80002aae <argstr>
    return -1;
    80005f88:	597d                	li	s2,-1
  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    80005f8a:	18054a63          	bltz	a0,8000611e <sys_open+0x1b6>
    80005f8e:	f4c40593          	addi	a1,s0,-180
    80005f92:	4505                	li	a0,1
    80005f94:	ffffd097          	auipc	ra,0xffffd
    80005f98:	ad6080e7          	jalr	-1322(ra) # 80002a6a <argint>
    80005f9c:	18054163          	bltz	a0,8000611e <sys_open+0x1b6>

  begin_op();
    80005fa0:	fffff097          	auipc	ra,0xfffff
    80005fa4:	8f8080e7          	jalr	-1800(ra) # 80004898 <begin_op>

  if(omode & O_CREATE){
    80005fa8:	f4c42783          	lw	a5,-180(s0)
    80005fac:	2007f793          	andi	a5,a5,512
    80005fb0:	c7d5                	beqz	a5,8000605c <sys_open+0xf4>
    ip = create(path, T_FILE, 0, 0);
    80005fb2:	4681                	li	a3,0
    80005fb4:	4601                	li	a2,0
    80005fb6:	4589                	li	a1,2
    80005fb8:	f5040513          	addi	a0,s0,-176
    80005fbc:	00000097          	auipc	ra,0x0
    80005fc0:	852080e7          	jalr	-1966(ra) # 8000580e <create>
    80005fc4:	84aa                	mv	s1,a0
    if(ip == 0){
    80005fc6:	c551                	beqz	a0,80006052 <sys_open+0xea>
      end_op();
      return -1;
    }
  }

  if(ip->type == T_DEVICE && (ip->major < 0 || ip->major >= NDEV)){
    80005fc8:	04449783          	lh	a5,68(s1)
    80005fcc:	0007869b          	sext.w	a3,a5
    80005fd0:	470d                	li	a4,3
    80005fd2:	0ce68a63          	beq	a3,a4,800060a6 <sys_open+0x13e>
    end_op();
    return -1;
  }
  
  // 处理软链接 打开设置为跟随软链接
  if(ip->type == T_SYMLINK && !(omode & O_NOFOLLOW)){
    80005fd6:	2781                	sext.w	a5,a5
    80005fd8:	4711                	li	a4,4
    80005fda:	0ce79b63          	bne	a5,a4,800060b0 <sys_open+0x148>
    80005fde:	f4c42783          	lw	a5,-180(s0)
    80005fe2:	83ad                	srli	a5,a5,0xb
    80005fe4:	8b85                	andi	a5,a5,1
    80005fe6:	e7e9                	bnez	a5,800060b0 <sys_open+0x148>
    80005fe8:	4929                	li	s2,10
        end_op();
        return -1;
      }
      ilock(ip);
      // 找到了最终指向的文件
      if(ip->type != T_SYMLINK)
    80005fea:	4991                	li	s3,4
      if(readi(ip, 0, (uint64)path, 0, MAXPATH) != MAXPATH){
    80005fec:	08000713          	li	a4,128
    80005ff0:	4681                	li	a3,0
    80005ff2:	f5040613          	addi	a2,s0,-176
    80005ff6:	4581                	li	a1,0
    80005ff8:	8526                	mv	a0,s1
    80005ffa:	ffffe097          	auipc	ra,0xffffe
    80005ffe:	a04080e7          	jalr	-1532(ra) # 800039fe <readi>
    80006002:	08000793          	li	a5,128
    80006006:	12f51f63          	bne	a0,a5,80006144 <sys_open+0x1dc>
      iunlockput(ip);
    8000600a:	8526                	mv	a0,s1
    8000600c:	ffffe097          	auipc	ra,0xffffe
    80006010:	9a0080e7          	jalr	-1632(ra) # 800039ac <iunlockput>
      if((ip = namei(path)) == 0){
    80006014:	f5040513          	addi	a0,s0,-176
    80006018:	ffffe097          	auipc	ra,0xffffe
    8000601c:	660080e7          	jalr	1632(ra) # 80004678 <namei>
    80006020:	84aa                	mv	s1,a0
    80006022:	12050c63          	beqz	a0,8000615a <sys_open+0x1f2>
      ilock(ip);
    80006026:	ffffd097          	auipc	ra,0xffffd
    8000602a:	67e080e7          	jalr	1662(ra) # 800036a4 <ilock>
      if(ip->type != T_SYMLINK)
    8000602e:	04449783          	lh	a5,68(s1)
    80006032:	07379f63          	bne	a5,s3,800060b0 <sys_open+0x148>
    for(int i = 0; i < SYMLINKMAXD; i++){
    80006036:	397d                	addiw	s2,s2,-1
    80006038:	fa091ae3          	bnez	s2,80005fec <sys_open+0x84>
        break;
    }
    // 达到最大深度仍为软链接
    if(ip->type == T_SYMLINK){
      // 失败返回
      iunlockput(ip);
    8000603c:	8526                	mv	a0,s1
    8000603e:	ffffe097          	auipc	ra,0xffffe
    80006042:	96e080e7          	jalr	-1682(ra) # 800039ac <iunlockput>
      end_op();
    80006046:	fffff097          	auipc	ra,0xfffff
    8000604a:	8d0080e7          	jalr	-1840(ra) # 80004916 <end_op>
      return -1;
    8000604e:	597d                	li	s2,-1
    80006050:	a0f9                	j	8000611e <sys_open+0x1b6>
      end_op();
    80006052:	fffff097          	auipc	ra,0xfffff
    80006056:	8c4080e7          	jalr	-1852(ra) # 80004916 <end_op>
      return -1;
    8000605a:	a0d1                	j	8000611e <sys_open+0x1b6>
    if((ip = namei(path)) == 0){
    8000605c:	f5040513          	addi	a0,s0,-176
    80006060:	ffffe097          	auipc	ra,0xffffe
    80006064:	618080e7          	jalr	1560(ra) # 80004678 <namei>
    80006068:	84aa                	mv	s1,a0
    8000606a:	c905                	beqz	a0,8000609a <sys_open+0x132>
    ilock(ip);
    8000606c:	ffffd097          	auipc	ra,0xffffd
    80006070:	638080e7          	jalr	1592(ra) # 800036a4 <ilock>
    if(ip->type == T_DIR && omode != O_RDONLY){
    80006074:	04449703          	lh	a4,68(s1)
    80006078:	4785                	li	a5,1
    8000607a:	f4f717e3          	bne	a4,a5,80005fc8 <sys_open+0x60>
    8000607e:	f4c42783          	lw	a5,-180(s0)
    80006082:	c79d                	beqz	a5,800060b0 <sys_open+0x148>
      iunlockput(ip);
    80006084:	8526                	mv	a0,s1
    80006086:	ffffe097          	auipc	ra,0xffffe
    8000608a:	926080e7          	jalr	-1754(ra) # 800039ac <iunlockput>
      end_op();
    8000608e:	fffff097          	auipc	ra,0xfffff
    80006092:	888080e7          	jalr	-1912(ra) # 80004916 <end_op>
      return -1;
    80006096:	597d                	li	s2,-1
    80006098:	a059                	j	8000611e <sys_open+0x1b6>
      end_op();
    8000609a:	fffff097          	auipc	ra,0xfffff
    8000609e:	87c080e7          	jalr	-1924(ra) # 80004916 <end_op>
      return -1;
    800060a2:	597d                	li	s2,-1
    800060a4:	a8ad                	j	8000611e <sys_open+0x1b6>
  if(ip->type == T_DEVICE && (ip->major < 0 || ip->major >= NDEV)){
    800060a6:	0464d703          	lhu	a4,70(s1)
    800060aa:	47a5                	li	a5,9
    800060ac:	08e7e163          	bltu	a5,a4,8000612e <sys_open+0x1c6>
    }
  }

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
    800060b0:	fffff097          	auipc	ra,0xfffff
    800060b4:	bfc080e7          	jalr	-1028(ra) # 80004cac <filealloc>
    800060b8:	89aa                	mv	s3,a0
    800060ba:	c961                	beqz	a0,8000618a <sys_open+0x222>
    800060bc:	fffff097          	auipc	ra,0xfffff
    800060c0:	710080e7          	jalr	1808(ra) # 800057cc <fdalloc>
    800060c4:	892a                	mv	s2,a0
    800060c6:	0a054d63          	bltz	a0,80006180 <sys_open+0x218>
    iunlockput(ip);
    end_op();
    return -1;
  }

  if(ip->type == T_DEVICE){
    800060ca:	04449703          	lh	a4,68(s1)
    800060ce:	478d                	li	a5,3
    800060d0:	08f70b63          	beq	a4,a5,80006166 <sys_open+0x1fe>
    f->type = FD_DEVICE;
    f->major = ip->major;
  } else {
    f->type = FD_INODE;
    800060d4:	4789                	li	a5,2
    800060d6:	00f9a023          	sw	a5,0(s3)
    f->off = 0;
    800060da:	0209a023          	sw	zero,32(s3)
  }
  f->ip = ip;
    800060de:	0099bc23          	sd	s1,24(s3)
  f->readable = !(omode & O_WRONLY);
    800060e2:	f4c42783          	lw	a5,-180(s0)
    800060e6:	0017c713          	xori	a4,a5,1
    800060ea:	8b05                	andi	a4,a4,1
    800060ec:	00e98423          	sb	a4,8(s3)
  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
    800060f0:	0037f713          	andi	a4,a5,3
    800060f4:	00e03733          	snez	a4,a4
    800060f8:	00e984a3          	sb	a4,9(s3)

  if((omode & O_TRUNC) && ip->type == T_FILE){
    800060fc:	4007f793          	andi	a5,a5,1024
    80006100:	c791                	beqz	a5,8000610c <sys_open+0x1a4>
    80006102:	04449703          	lh	a4,68(s1)
    80006106:	4789                	li	a5,2
    80006108:	06f70663          	beq	a4,a5,80006174 <sys_open+0x20c>
    itrunc(ip);
  }

  iunlock(ip);
    8000610c:	8526                	mv	a0,s1
    8000610e:	ffffd097          	auipc	ra,0xffffd
    80006112:	658080e7          	jalr	1624(ra) # 80003766 <iunlock>
  end_op();
    80006116:	fffff097          	auipc	ra,0xfffff
    8000611a:	800080e7          	jalr	-2048(ra) # 80004916 <end_op>

  return fd;
}
    8000611e:	854a                	mv	a0,s2
    80006120:	70ea                	ld	ra,184(sp)
    80006122:	744a                	ld	s0,176(sp)
    80006124:	74aa                	ld	s1,168(sp)
    80006126:	790a                	ld	s2,160(sp)
    80006128:	69ea                	ld	s3,152(sp)
    8000612a:	6129                	addi	sp,sp,192
    8000612c:	8082                	ret
    iunlockput(ip);
    8000612e:	8526                	mv	a0,s1
    80006130:	ffffe097          	auipc	ra,0xffffe
    80006134:	87c080e7          	jalr	-1924(ra) # 800039ac <iunlockput>
    end_op();
    80006138:	ffffe097          	auipc	ra,0xffffe
    8000613c:	7de080e7          	jalr	2014(ra) # 80004916 <end_op>
    return -1;
    80006140:	597d                	li	s2,-1
    80006142:	bff1                	j	8000611e <sys_open+0x1b6>
        iunlockput(ip);
    80006144:	8526                	mv	a0,s1
    80006146:	ffffe097          	auipc	ra,0xffffe
    8000614a:	866080e7          	jalr	-1946(ra) # 800039ac <iunlockput>
        end_op();
    8000614e:	ffffe097          	auipc	ra,0xffffe
    80006152:	7c8080e7          	jalr	1992(ra) # 80004916 <end_op>
        return -1;
    80006156:	597d                	li	s2,-1
    80006158:	b7d9                	j	8000611e <sys_open+0x1b6>
        end_op();
    8000615a:	ffffe097          	auipc	ra,0xffffe
    8000615e:	7bc080e7          	jalr	1980(ra) # 80004916 <end_op>
        return -1;
    80006162:	597d                	li	s2,-1
    80006164:	bf6d                	j	8000611e <sys_open+0x1b6>
    f->type = FD_DEVICE;
    80006166:	00f9a023          	sw	a5,0(s3)
    f->major = ip->major;
    8000616a:	04649783          	lh	a5,70(s1)
    8000616e:	02f99223          	sh	a5,36(s3)
    80006172:	b7b5                	j	800060de <sys_open+0x176>
    itrunc(ip);
    80006174:	8526                	mv	a0,s1
    80006176:	ffffd097          	auipc	ra,0xffffd
    8000617a:	63c080e7          	jalr	1596(ra) # 800037b2 <itrunc>
    8000617e:	b779                	j	8000610c <sys_open+0x1a4>
      fileclose(f);
    80006180:	854e                	mv	a0,s3
    80006182:	fffff097          	auipc	ra,0xfffff
    80006186:	be6080e7          	jalr	-1050(ra) # 80004d68 <fileclose>
    iunlockput(ip);
    8000618a:	8526                	mv	a0,s1
    8000618c:	ffffe097          	auipc	ra,0xffffe
    80006190:	820080e7          	jalr	-2016(ra) # 800039ac <iunlockput>
    end_op();
    80006194:	ffffe097          	auipc	ra,0xffffe
    80006198:	782080e7          	jalr	1922(ra) # 80004916 <end_op>
    return -1;
    8000619c:	597d                	li	s2,-1
    8000619e:	b741                	j	8000611e <sys_open+0x1b6>

00000000800061a0 <sys_mkdir>:

uint64
sys_mkdir(void)
{
    800061a0:	7175                	addi	sp,sp,-144
    800061a2:	e506                	sd	ra,136(sp)
    800061a4:	e122                	sd	s0,128(sp)
    800061a6:	0900                	addi	s0,sp,144
  char path[MAXPATH];
  struct inode *ip;

  begin_op();
    800061a8:	ffffe097          	auipc	ra,0xffffe
    800061ac:	6f0080e7          	jalr	1776(ra) # 80004898 <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){
    800061b0:	08000613          	li	a2,128
    800061b4:	f7040593          	addi	a1,s0,-144
    800061b8:	4501                	li	a0,0
    800061ba:	ffffd097          	auipc	ra,0xffffd
    800061be:	8f4080e7          	jalr	-1804(ra) # 80002aae <argstr>
    800061c2:	02054963          	bltz	a0,800061f4 <sys_mkdir+0x54>
    800061c6:	4681                	li	a3,0
    800061c8:	4601                	li	a2,0
    800061ca:	4585                	li	a1,1
    800061cc:	f7040513          	addi	a0,s0,-144
    800061d0:	fffff097          	auipc	ra,0xfffff
    800061d4:	63e080e7          	jalr	1598(ra) # 8000580e <create>
    800061d8:	cd11                	beqz	a0,800061f4 <sys_mkdir+0x54>
    end_op();
    return -1;
  }
  iunlockput(ip);
    800061da:	ffffd097          	auipc	ra,0xffffd
    800061de:	7d2080e7          	jalr	2002(ra) # 800039ac <iunlockput>
  end_op();
    800061e2:	ffffe097          	auipc	ra,0xffffe
    800061e6:	734080e7          	jalr	1844(ra) # 80004916 <end_op>
  return 0;
    800061ea:	4501                	li	a0,0
}
    800061ec:	60aa                	ld	ra,136(sp)
    800061ee:	640a                	ld	s0,128(sp)
    800061f0:	6149                	addi	sp,sp,144
    800061f2:	8082                	ret
    end_op();
    800061f4:	ffffe097          	auipc	ra,0xffffe
    800061f8:	722080e7          	jalr	1826(ra) # 80004916 <end_op>
    return -1;
    800061fc:	557d                	li	a0,-1
    800061fe:	b7fd                	j	800061ec <sys_mkdir+0x4c>

0000000080006200 <sys_mknod>:

uint64
sys_mknod(void)
{
    80006200:	7135                	addi	sp,sp,-160
    80006202:	ed06                	sd	ra,152(sp)
    80006204:	e922                	sd	s0,144(sp)
    80006206:	1100                	addi	s0,sp,160
  struct inode *ip;
  char path[MAXPATH];
  int major, minor;

  begin_op();
    80006208:	ffffe097          	auipc	ra,0xffffe
    8000620c:	690080e7          	jalr	1680(ra) # 80004898 <begin_op>
  if((argstr(0, path, MAXPATH)) < 0 ||
    80006210:	08000613          	li	a2,128
    80006214:	f7040593          	addi	a1,s0,-144
    80006218:	4501                	li	a0,0
    8000621a:	ffffd097          	auipc	ra,0xffffd
    8000621e:	894080e7          	jalr	-1900(ra) # 80002aae <argstr>
    80006222:	04054a63          	bltz	a0,80006276 <sys_mknod+0x76>
     argint(1, &major) < 0 ||
    80006226:	f6c40593          	addi	a1,s0,-148
    8000622a:	4505                	li	a0,1
    8000622c:	ffffd097          	auipc	ra,0xffffd
    80006230:	83e080e7          	jalr	-1986(ra) # 80002a6a <argint>
  if((argstr(0, path, MAXPATH)) < 0 ||
    80006234:	04054163          	bltz	a0,80006276 <sys_mknod+0x76>
     argint(2, &minor) < 0 ||
    80006238:	f6840593          	addi	a1,s0,-152
    8000623c:	4509                	li	a0,2
    8000623e:	ffffd097          	auipc	ra,0xffffd
    80006242:	82c080e7          	jalr	-2004(ra) # 80002a6a <argint>
     argint(1, &major) < 0 ||
    80006246:	02054863          	bltz	a0,80006276 <sys_mknod+0x76>
     (ip = create(path, T_DEVICE, major, minor)) == 0){
    8000624a:	f6841683          	lh	a3,-152(s0)
    8000624e:	f6c41603          	lh	a2,-148(s0)
    80006252:	458d                	li	a1,3
    80006254:	f7040513          	addi	a0,s0,-144
    80006258:	fffff097          	auipc	ra,0xfffff
    8000625c:	5b6080e7          	jalr	1462(ra) # 8000580e <create>
     argint(2, &minor) < 0 ||
    80006260:	c919                	beqz	a0,80006276 <sys_mknod+0x76>
    end_op();
    return -1;
  }
  iunlockput(ip);
    80006262:	ffffd097          	auipc	ra,0xffffd
    80006266:	74a080e7          	jalr	1866(ra) # 800039ac <iunlockput>
  end_op();
    8000626a:	ffffe097          	auipc	ra,0xffffe
    8000626e:	6ac080e7          	jalr	1708(ra) # 80004916 <end_op>
  return 0;
    80006272:	4501                	li	a0,0
    80006274:	a031                	j	80006280 <sys_mknod+0x80>
    end_op();
    80006276:	ffffe097          	auipc	ra,0xffffe
    8000627a:	6a0080e7          	jalr	1696(ra) # 80004916 <end_op>
    return -1;
    8000627e:	557d                	li	a0,-1
}
    80006280:	60ea                	ld	ra,152(sp)
    80006282:	644a                	ld	s0,144(sp)
    80006284:	610d                	addi	sp,sp,160
    80006286:	8082                	ret

0000000080006288 <sys_chdir>:

uint64
sys_chdir(void)
{
    80006288:	7135                	addi	sp,sp,-160
    8000628a:	ed06                	sd	ra,152(sp)
    8000628c:	e922                	sd	s0,144(sp)
    8000628e:	e526                	sd	s1,136(sp)
    80006290:	e14a                	sd	s2,128(sp)
    80006292:	1100                	addi	s0,sp,160
  char path[MAXPATH];
  struct inode *ip;
  struct proc *p = myproc();
    80006294:	ffffb097          	auipc	ra,0xffffb
    80006298:	716080e7          	jalr	1814(ra) # 800019aa <myproc>
    8000629c:	892a                	mv	s2,a0
  
  begin_op();
    8000629e:	ffffe097          	auipc	ra,0xffffe
    800062a2:	5fa080e7          	jalr	1530(ra) # 80004898 <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = namei(path)) == 0){
    800062a6:	08000613          	li	a2,128
    800062aa:	f6040593          	addi	a1,s0,-160
    800062ae:	4501                	li	a0,0
    800062b0:	ffffc097          	auipc	ra,0xffffc
    800062b4:	7fe080e7          	jalr	2046(ra) # 80002aae <argstr>
    800062b8:	04054b63          	bltz	a0,8000630e <sys_chdir+0x86>
    800062bc:	f6040513          	addi	a0,s0,-160
    800062c0:	ffffe097          	auipc	ra,0xffffe
    800062c4:	3b8080e7          	jalr	952(ra) # 80004678 <namei>
    800062c8:	84aa                	mv	s1,a0
    800062ca:	c131                	beqz	a0,8000630e <sys_chdir+0x86>
    end_op();
    return -1;
  }
  ilock(ip);
    800062cc:	ffffd097          	auipc	ra,0xffffd
    800062d0:	3d8080e7          	jalr	984(ra) # 800036a4 <ilock>
  if(ip->type != T_DIR){
    800062d4:	04449703          	lh	a4,68(s1)
    800062d8:	4785                	li	a5,1
    800062da:	04f71063          	bne	a4,a5,8000631a <sys_chdir+0x92>
    iunlockput(ip);
    end_op();
    return -1;
  }
  iunlock(ip);
    800062de:	8526                	mv	a0,s1
    800062e0:	ffffd097          	auipc	ra,0xffffd
    800062e4:	486080e7          	jalr	1158(ra) # 80003766 <iunlock>
  iput(p->cwd);
    800062e8:	15093503          	ld	a0,336(s2)
    800062ec:	ffffd097          	auipc	ra,0xffffd
    800062f0:	618080e7          	jalr	1560(ra) # 80003904 <iput>
  end_op();
    800062f4:	ffffe097          	auipc	ra,0xffffe
    800062f8:	622080e7          	jalr	1570(ra) # 80004916 <end_op>
  p->cwd = ip;
    800062fc:	14993823          	sd	s1,336(s2)
  return 0;
    80006300:	4501                	li	a0,0
}
    80006302:	60ea                	ld	ra,152(sp)
    80006304:	644a                	ld	s0,144(sp)
    80006306:	64aa                	ld	s1,136(sp)
    80006308:	690a                	ld	s2,128(sp)
    8000630a:	610d                	addi	sp,sp,160
    8000630c:	8082                	ret
    end_op();
    8000630e:	ffffe097          	auipc	ra,0xffffe
    80006312:	608080e7          	jalr	1544(ra) # 80004916 <end_op>
    return -1;
    80006316:	557d                	li	a0,-1
    80006318:	b7ed                	j	80006302 <sys_chdir+0x7a>
    iunlockput(ip);
    8000631a:	8526                	mv	a0,s1
    8000631c:	ffffd097          	auipc	ra,0xffffd
    80006320:	690080e7          	jalr	1680(ra) # 800039ac <iunlockput>
    end_op();
    80006324:	ffffe097          	auipc	ra,0xffffe
    80006328:	5f2080e7          	jalr	1522(ra) # 80004916 <end_op>
    return -1;
    8000632c:	557d                	li	a0,-1
    8000632e:	bfd1                	j	80006302 <sys_chdir+0x7a>

0000000080006330 <sys_exec>:

uint64
sys_exec(void)
{
    80006330:	7145                	addi	sp,sp,-464
    80006332:	e786                	sd	ra,456(sp)
    80006334:	e3a2                	sd	s0,448(sp)
    80006336:	ff26                	sd	s1,440(sp)
    80006338:	fb4a                	sd	s2,432(sp)
    8000633a:	f74e                	sd	s3,424(sp)
    8000633c:	f352                	sd	s4,416(sp)
    8000633e:	ef56                	sd	s5,408(sp)
    80006340:	0b80                	addi	s0,sp,464
  char path[MAXPATH], *argv[MAXARG];
  int i;
  uint64 uargv, uarg;

  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80006342:	08000613          	li	a2,128
    80006346:	f4040593          	addi	a1,s0,-192
    8000634a:	4501                	li	a0,0
    8000634c:	ffffc097          	auipc	ra,0xffffc
    80006350:	762080e7          	jalr	1890(ra) # 80002aae <argstr>
    return -1;
    80006354:	597d                	li	s2,-1
  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80006356:	0c054b63          	bltz	a0,8000642c <sys_exec+0xfc>
    8000635a:	e3840593          	addi	a1,s0,-456
    8000635e:	4505                	li	a0,1
    80006360:	ffffc097          	auipc	ra,0xffffc
    80006364:	72c080e7          	jalr	1836(ra) # 80002a8c <argaddr>
    80006368:	0c054263          	bltz	a0,8000642c <sys_exec+0xfc>
  }
  memset(argv, 0, sizeof(argv));
    8000636c:	10000613          	li	a2,256
    80006370:	4581                	li	a1,0
    80006372:	e4040513          	addi	a0,s0,-448
    80006376:	ffffb097          	auipc	ra,0xffffb
    8000637a:	948080e7          	jalr	-1720(ra) # 80000cbe <memset>
  for(i=0;; i++){
    if(i >= NELEM(argv)){
    8000637e:	e4040493          	addi	s1,s0,-448
  memset(argv, 0, sizeof(argv));
    80006382:	89a6                	mv	s3,s1
    80006384:	4901                	li	s2,0
    if(i >= NELEM(argv)){
    80006386:	02000a13          	li	s4,32
    8000638a:	00090a9b          	sext.w	s5,s2
      goto bad;
    }
    if(fetchaddr(uargv+sizeof(uint64)*i, (uint64*)&uarg) < 0){
    8000638e:	00391513          	slli	a0,s2,0x3
    80006392:	e3040593          	addi	a1,s0,-464
    80006396:	e3843783          	ld	a5,-456(s0)
    8000639a:	953e                	add	a0,a0,a5
    8000639c:	ffffc097          	auipc	ra,0xffffc
    800063a0:	634080e7          	jalr	1588(ra) # 800029d0 <fetchaddr>
    800063a4:	02054a63          	bltz	a0,800063d8 <sys_exec+0xa8>
      goto bad;
    }
    if(uarg == 0){
    800063a8:	e3043783          	ld	a5,-464(s0)
    800063ac:	c3b9                	beqz	a5,800063f2 <sys_exec+0xc2>
      argv[i] = 0;
      break;
    }
    argv[i] = kalloc();
    800063ae:	ffffa097          	auipc	ra,0xffffa
    800063b2:	724080e7          	jalr	1828(ra) # 80000ad2 <kalloc>
    800063b6:	85aa                	mv	a1,a0
    800063b8:	00a9b023          	sd	a0,0(s3)
    if(argv[i] == 0)
    800063bc:	cd11                	beqz	a0,800063d8 <sys_exec+0xa8>
      goto bad;
    if(fetchstr(uarg, argv[i], PGSIZE) < 0)
    800063be:	6605                	lui	a2,0x1
    800063c0:	e3043503          	ld	a0,-464(s0)
    800063c4:	ffffc097          	auipc	ra,0xffffc
    800063c8:	65e080e7          	jalr	1630(ra) # 80002a22 <fetchstr>
    800063cc:	00054663          	bltz	a0,800063d8 <sys_exec+0xa8>
    if(i >= NELEM(argv)){
    800063d0:	0905                	addi	s2,s2,1
    800063d2:	09a1                	addi	s3,s3,8
    800063d4:	fb491be3          	bne	s2,s4,8000638a <sys_exec+0x5a>
    kfree(argv[i]);

  return ret;

 bad:
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    800063d8:	f4040913          	addi	s2,s0,-192
    800063dc:	6088                	ld	a0,0(s1)
    800063de:	c531                	beqz	a0,8000642a <sys_exec+0xfa>
    kfree(argv[i]);
    800063e0:	ffffa097          	auipc	ra,0xffffa
    800063e4:	5f4080e7          	jalr	1524(ra) # 800009d4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    800063e8:	04a1                	addi	s1,s1,8
    800063ea:	ff2499e3          	bne	s1,s2,800063dc <sys_exec+0xac>
  return -1;
    800063ee:	597d                	li	s2,-1
    800063f0:	a835                	j	8000642c <sys_exec+0xfc>
      argv[i] = 0;
    800063f2:	0a8e                	slli	s5,s5,0x3
    800063f4:	fc0a8793          	addi	a5,s5,-64 # ffffffffffffefc0 <end+0xffffffff7ffddfc0>
    800063f8:	00878ab3          	add	s5,a5,s0
    800063fc:	e80ab023          	sd	zero,-384(s5)
  int ret = exec(path, argv);
    80006400:	e4040593          	addi	a1,s0,-448
    80006404:	f4040513          	addi	a0,s0,-192
    80006408:	fffff097          	auipc	ra,0xfffff
    8000640c:	fb4080e7          	jalr	-76(ra) # 800053bc <exec>
    80006410:	892a                	mv	s2,a0
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80006412:	f4040993          	addi	s3,s0,-192
    80006416:	6088                	ld	a0,0(s1)
    80006418:	c911                	beqz	a0,8000642c <sys_exec+0xfc>
    kfree(argv[i]);
    8000641a:	ffffa097          	auipc	ra,0xffffa
    8000641e:	5ba080e7          	jalr	1466(ra) # 800009d4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80006422:	04a1                	addi	s1,s1,8
    80006424:	ff3499e3          	bne	s1,s3,80006416 <sys_exec+0xe6>
    80006428:	a011                	j	8000642c <sys_exec+0xfc>
  return -1;
    8000642a:	597d                	li	s2,-1
}
    8000642c:	854a                	mv	a0,s2
    8000642e:	60be                	ld	ra,456(sp)
    80006430:	641e                	ld	s0,448(sp)
    80006432:	74fa                	ld	s1,440(sp)
    80006434:	795a                	ld	s2,432(sp)
    80006436:	79ba                	ld	s3,424(sp)
    80006438:	7a1a                	ld	s4,416(sp)
    8000643a:	6afa                	ld	s5,408(sp)
    8000643c:	6179                	addi	sp,sp,464
    8000643e:	8082                	ret

0000000080006440 <sys_pipe>:

uint64
sys_pipe(void)
{
    80006440:	7139                	addi	sp,sp,-64
    80006442:	fc06                	sd	ra,56(sp)
    80006444:	f822                	sd	s0,48(sp)
    80006446:	f426                	sd	s1,40(sp)
    80006448:	0080                	addi	s0,sp,64
  uint64 fdarray; // user pointer to array of two integers
  struct file *rf, *wf;
  int fd0, fd1;
  struct proc *p = myproc();
    8000644a:	ffffb097          	auipc	ra,0xffffb
    8000644e:	560080e7          	jalr	1376(ra) # 800019aa <myproc>
    80006452:	84aa                	mv	s1,a0

  if(argaddr(0, &fdarray) < 0)
    80006454:	fd840593          	addi	a1,s0,-40
    80006458:	4501                	li	a0,0
    8000645a:	ffffc097          	auipc	ra,0xffffc
    8000645e:	632080e7          	jalr	1586(ra) # 80002a8c <argaddr>
    return -1;
    80006462:	57fd                	li	a5,-1
  if(argaddr(0, &fdarray) < 0)
    80006464:	0e054063          	bltz	a0,80006544 <sys_pipe+0x104>
  if(pipealloc(&rf, &wf) < 0)
    80006468:	fc840593          	addi	a1,s0,-56
    8000646c:	fd040513          	addi	a0,s0,-48
    80006470:	fffff097          	auipc	ra,0xfffff
    80006474:	c28080e7          	jalr	-984(ra) # 80005098 <pipealloc>
    return -1;
    80006478:	57fd                	li	a5,-1
  if(pipealloc(&rf, &wf) < 0)
    8000647a:	0c054563          	bltz	a0,80006544 <sys_pipe+0x104>
  fd0 = -1;
    8000647e:	fcf42223          	sw	a5,-60(s0)
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    80006482:	fd043503          	ld	a0,-48(s0)
    80006486:	fffff097          	auipc	ra,0xfffff
    8000648a:	346080e7          	jalr	838(ra) # 800057cc <fdalloc>
    8000648e:	fca42223          	sw	a0,-60(s0)
    80006492:	08054c63          	bltz	a0,8000652a <sys_pipe+0xea>
    80006496:	fc843503          	ld	a0,-56(s0)
    8000649a:	fffff097          	auipc	ra,0xfffff
    8000649e:	332080e7          	jalr	818(ra) # 800057cc <fdalloc>
    800064a2:	fca42023          	sw	a0,-64(s0)
    800064a6:	06054963          	bltz	a0,80006518 <sys_pipe+0xd8>
      p->ofile[fd0] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    800064aa:	4691                	li	a3,4
    800064ac:	fc440613          	addi	a2,s0,-60
    800064b0:	fd843583          	ld	a1,-40(s0)
    800064b4:	68a8                	ld	a0,80(s1)
    800064b6:	ffffb097          	auipc	ra,0xffffb
    800064ba:	18c080e7          	jalr	396(ra) # 80001642 <copyout>
    800064be:	02054063          	bltz	a0,800064de <sys_pipe+0x9e>
     copyout(p->pagetable, fdarray+sizeof(fd0), (char *)&fd1, sizeof(fd1)) < 0){
    800064c2:	4691                	li	a3,4
    800064c4:	fc040613          	addi	a2,s0,-64
    800064c8:	fd843583          	ld	a1,-40(s0)
    800064cc:	0591                	addi	a1,a1,4
    800064ce:	68a8                	ld	a0,80(s1)
    800064d0:	ffffb097          	auipc	ra,0xffffb
    800064d4:	172080e7          	jalr	370(ra) # 80001642 <copyout>
    p->ofile[fd1] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  return 0;
    800064d8:	4781                	li	a5,0
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    800064da:	06055563          	bgez	a0,80006544 <sys_pipe+0x104>
    p->ofile[fd0] = 0;
    800064de:	fc442783          	lw	a5,-60(s0)
    800064e2:	07e9                	addi	a5,a5,26
    800064e4:	078e                	slli	a5,a5,0x3
    800064e6:	97a6                	add	a5,a5,s1
    800064e8:	0007b023          	sd	zero,0(a5)
    p->ofile[fd1] = 0;
    800064ec:	fc042783          	lw	a5,-64(s0)
    800064f0:	07e9                	addi	a5,a5,26
    800064f2:	078e                	slli	a5,a5,0x3
    800064f4:	00f48533          	add	a0,s1,a5
    800064f8:	00053023          	sd	zero,0(a0)
    fileclose(rf);
    800064fc:	fd043503          	ld	a0,-48(s0)
    80006500:	fffff097          	auipc	ra,0xfffff
    80006504:	868080e7          	jalr	-1944(ra) # 80004d68 <fileclose>
    fileclose(wf);
    80006508:	fc843503          	ld	a0,-56(s0)
    8000650c:	fffff097          	auipc	ra,0xfffff
    80006510:	85c080e7          	jalr	-1956(ra) # 80004d68 <fileclose>
    return -1;
    80006514:	57fd                	li	a5,-1
    80006516:	a03d                	j	80006544 <sys_pipe+0x104>
    if(fd0 >= 0)
    80006518:	fc442783          	lw	a5,-60(s0)
    8000651c:	0007c763          	bltz	a5,8000652a <sys_pipe+0xea>
      p->ofile[fd0] = 0;
    80006520:	07e9                	addi	a5,a5,26
    80006522:	078e                	slli	a5,a5,0x3
    80006524:	97a6                	add	a5,a5,s1
    80006526:	0007b023          	sd	zero,0(a5)
    fileclose(rf);
    8000652a:	fd043503          	ld	a0,-48(s0)
    8000652e:	fffff097          	auipc	ra,0xfffff
    80006532:	83a080e7          	jalr	-1990(ra) # 80004d68 <fileclose>
    fileclose(wf);
    80006536:	fc843503          	ld	a0,-56(s0)
    8000653a:	fffff097          	auipc	ra,0xfffff
    8000653e:	82e080e7          	jalr	-2002(ra) # 80004d68 <fileclose>
    return -1;
    80006542:	57fd                	li	a5,-1
}
    80006544:	853e                	mv	a0,a5
    80006546:	70e2                	ld	ra,56(sp)
    80006548:	7442                	ld	s0,48(sp)
    8000654a:	74a2                	ld	s1,40(sp)
    8000654c:	6121                	addi	sp,sp,64
    8000654e:	8082                	ret

0000000080006550 <kernelvec>:
    80006550:	7111                	addi	sp,sp,-256
    80006552:	e006                	sd	ra,0(sp)
    80006554:	e40a                	sd	sp,8(sp)
    80006556:	e80e                	sd	gp,16(sp)
    80006558:	ec12                	sd	tp,24(sp)
    8000655a:	f016                	sd	t0,32(sp)
    8000655c:	f41a                	sd	t1,40(sp)
    8000655e:	f81e                	sd	t2,48(sp)
    80006560:	fc22                	sd	s0,56(sp)
    80006562:	e0a6                	sd	s1,64(sp)
    80006564:	e4aa                	sd	a0,72(sp)
    80006566:	e8ae                	sd	a1,80(sp)
    80006568:	ecb2                	sd	a2,88(sp)
    8000656a:	f0b6                	sd	a3,96(sp)
    8000656c:	f4ba                	sd	a4,104(sp)
    8000656e:	f8be                	sd	a5,112(sp)
    80006570:	fcc2                	sd	a6,120(sp)
    80006572:	e146                	sd	a7,128(sp)
    80006574:	e54a                	sd	s2,136(sp)
    80006576:	e94e                	sd	s3,144(sp)
    80006578:	ed52                	sd	s4,152(sp)
    8000657a:	f156                	sd	s5,160(sp)
    8000657c:	f55a                	sd	s6,168(sp)
    8000657e:	f95e                	sd	s7,176(sp)
    80006580:	fd62                	sd	s8,184(sp)
    80006582:	e1e6                	sd	s9,192(sp)
    80006584:	e5ea                	sd	s10,200(sp)
    80006586:	e9ee                	sd	s11,208(sp)
    80006588:	edf2                	sd	t3,216(sp)
    8000658a:	f1f6                	sd	t4,224(sp)
    8000658c:	f5fa                	sd	t5,232(sp)
    8000658e:	f9fe                	sd	t6,240(sp)
    80006590:	b0cfc0ef          	jal	ra,8000289c <kerneltrap>
    80006594:	6082                	ld	ra,0(sp)
    80006596:	6122                	ld	sp,8(sp)
    80006598:	61c2                	ld	gp,16(sp)
    8000659a:	7282                	ld	t0,32(sp)
    8000659c:	7322                	ld	t1,40(sp)
    8000659e:	73c2                	ld	t2,48(sp)
    800065a0:	7462                	ld	s0,56(sp)
    800065a2:	6486                	ld	s1,64(sp)
    800065a4:	6526                	ld	a0,72(sp)
    800065a6:	65c6                	ld	a1,80(sp)
    800065a8:	6666                	ld	a2,88(sp)
    800065aa:	7686                	ld	a3,96(sp)
    800065ac:	7726                	ld	a4,104(sp)
    800065ae:	77c6                	ld	a5,112(sp)
    800065b0:	7866                	ld	a6,120(sp)
    800065b2:	688a                	ld	a7,128(sp)
    800065b4:	692a                	ld	s2,136(sp)
    800065b6:	69ca                	ld	s3,144(sp)
    800065b8:	6a6a                	ld	s4,152(sp)
    800065ba:	7a8a                	ld	s5,160(sp)
    800065bc:	7b2a                	ld	s6,168(sp)
    800065be:	7bca                	ld	s7,176(sp)
    800065c0:	7c6a                	ld	s8,184(sp)
    800065c2:	6c8e                	ld	s9,192(sp)
    800065c4:	6d2e                	ld	s10,200(sp)
    800065c6:	6dce                	ld	s11,208(sp)
    800065c8:	6e6e                	ld	t3,216(sp)
    800065ca:	7e8e                	ld	t4,224(sp)
    800065cc:	7f2e                	ld	t5,232(sp)
    800065ce:	7fce                	ld	t6,240(sp)
    800065d0:	6111                	addi	sp,sp,256
    800065d2:	10200073          	sret
    800065d6:	00000013          	nop
    800065da:	00000013          	nop
    800065de:	0001                	nop

00000000800065e0 <timervec>:
    800065e0:	34051573          	csrrw	a0,mscratch,a0
    800065e4:	e10c                	sd	a1,0(a0)
    800065e6:	e510                	sd	a2,8(a0)
    800065e8:	e914                	sd	a3,16(a0)
    800065ea:	6d0c                	ld	a1,24(a0)
    800065ec:	7110                	ld	a2,32(a0)
    800065ee:	6194                	ld	a3,0(a1)
    800065f0:	96b2                	add	a3,a3,a2
    800065f2:	e194                	sd	a3,0(a1)
    800065f4:	4589                	li	a1,2
    800065f6:	14459073          	csrw	sip,a1
    800065fa:	6914                	ld	a3,16(a0)
    800065fc:	6510                	ld	a2,8(a0)
    800065fe:	610c                	ld	a1,0(a0)
    80006600:	34051573          	csrrw	a0,mscratch,a0
    80006604:	30200073          	mret
	...

000000008000660a <plicinit>:
// the riscv Platform Level Interrupt Controller (PLIC).
//

void
plicinit(void)
{
    8000660a:	1141                	addi	sp,sp,-16
    8000660c:	e422                	sd	s0,8(sp)
    8000660e:	0800                	addi	s0,sp,16
  // set desired IRQ priorities non-zero (otherwise disabled).
  *(uint32*)(PLIC + UART0_IRQ*4) = 1;
    80006610:	0c0007b7          	lui	a5,0xc000
    80006614:	4705                	li	a4,1
    80006616:	d798                	sw	a4,40(a5)
  *(uint32*)(PLIC + VIRTIO0_IRQ*4) = 1;
    80006618:	c3d8                	sw	a4,4(a5)
}
    8000661a:	6422                	ld	s0,8(sp)
    8000661c:	0141                	addi	sp,sp,16
    8000661e:	8082                	ret

0000000080006620 <plicinithart>:

void
plicinithart(void)
{
    80006620:	1141                	addi	sp,sp,-16
    80006622:	e406                	sd	ra,8(sp)
    80006624:	e022                	sd	s0,0(sp)
    80006626:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80006628:	ffffb097          	auipc	ra,0xffffb
    8000662c:	356080e7          	jalr	854(ra) # 8000197e <cpuid>
  
  // set uart's enable bit for this hart's S-mode. 
  *(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ);
    80006630:	0085171b          	slliw	a4,a0,0x8
    80006634:	0c0027b7          	lui	a5,0xc002
    80006638:	97ba                	add	a5,a5,a4
    8000663a:	40200713          	li	a4,1026
    8000663e:	08e7a023          	sw	a4,128(a5) # c002080 <_entry-0x73ffdf80>

  // set this hart's S-mode priority threshold to 0.
  *(uint32*)PLIC_SPRIORITY(hart) = 0;
    80006642:	00d5151b          	slliw	a0,a0,0xd
    80006646:	0c2017b7          	lui	a5,0xc201
    8000664a:	97aa                	add	a5,a5,a0
    8000664c:	0007a023          	sw	zero,0(a5) # c201000 <_entry-0x73dff000>
}
    80006650:	60a2                	ld	ra,8(sp)
    80006652:	6402                	ld	s0,0(sp)
    80006654:	0141                	addi	sp,sp,16
    80006656:	8082                	ret

0000000080006658 <plic_claim>:

// ask the PLIC what interrupt we should serve.
int
plic_claim(void)
{
    80006658:	1141                	addi	sp,sp,-16
    8000665a:	e406                	sd	ra,8(sp)
    8000665c:	e022                	sd	s0,0(sp)
    8000665e:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80006660:	ffffb097          	auipc	ra,0xffffb
    80006664:	31e080e7          	jalr	798(ra) # 8000197e <cpuid>
  int irq = *(uint32*)PLIC_SCLAIM(hart);
    80006668:	00d5151b          	slliw	a0,a0,0xd
    8000666c:	0c2017b7          	lui	a5,0xc201
    80006670:	97aa                	add	a5,a5,a0
  return irq;
}
    80006672:	43c8                	lw	a0,4(a5)
    80006674:	60a2                	ld	ra,8(sp)
    80006676:	6402                	ld	s0,0(sp)
    80006678:	0141                	addi	sp,sp,16
    8000667a:	8082                	ret

000000008000667c <plic_complete>:

// tell the PLIC we've served this IRQ.
void
plic_complete(int irq)
{
    8000667c:	1101                	addi	sp,sp,-32
    8000667e:	ec06                	sd	ra,24(sp)
    80006680:	e822                	sd	s0,16(sp)
    80006682:	e426                	sd	s1,8(sp)
    80006684:	1000                	addi	s0,sp,32
    80006686:	84aa                	mv	s1,a0
  int hart = cpuid();
    80006688:	ffffb097          	auipc	ra,0xffffb
    8000668c:	2f6080e7          	jalr	758(ra) # 8000197e <cpuid>
  *(uint32*)PLIC_SCLAIM(hart) = irq;
    80006690:	00d5151b          	slliw	a0,a0,0xd
    80006694:	0c2017b7          	lui	a5,0xc201
    80006698:	97aa                	add	a5,a5,a0
    8000669a:	c3c4                	sw	s1,4(a5)
}
    8000669c:	60e2                	ld	ra,24(sp)
    8000669e:	6442                	ld	s0,16(sp)
    800066a0:	64a2                	ld	s1,8(sp)
    800066a2:	6105                	addi	sp,sp,32
    800066a4:	8082                	ret

00000000800066a6 <free_desc>:
}

// mark a descriptor as free.
static void
free_desc(int i)
{
    800066a6:	1141                	addi	sp,sp,-16
    800066a8:	e406                	sd	ra,8(sp)
    800066aa:	e022                	sd	s0,0(sp)
    800066ac:	0800                	addi	s0,sp,16
  if(i >= NUM)
    800066ae:	479d                	li	a5,7
    800066b0:	06a7c863          	blt	a5,a0,80006720 <free_desc+0x7a>
    panic("free_desc 1");
  if(disk.free[i])
    800066b4:	00018717          	auipc	a4,0x18
    800066b8:	94c70713          	addi	a4,a4,-1716 # 8001e000 <disk>
    800066bc:	972a                	add	a4,a4,a0
    800066be:	6789                	lui	a5,0x2
    800066c0:	97ba                	add	a5,a5,a4
    800066c2:	0187c783          	lbu	a5,24(a5) # 2018 <_entry-0x7fffdfe8>
    800066c6:	e7ad                	bnez	a5,80006730 <free_desc+0x8a>
    panic("free_desc 2");
  disk.desc[i].addr = 0;
    800066c8:	00451793          	slli	a5,a0,0x4
    800066cc:	0001a717          	auipc	a4,0x1a
    800066d0:	93470713          	addi	a4,a4,-1740 # 80020000 <disk+0x2000>
    800066d4:	6314                	ld	a3,0(a4)
    800066d6:	96be                	add	a3,a3,a5
    800066d8:	0006b023          	sd	zero,0(a3)
  disk.desc[i].len = 0;
    800066dc:	6314                	ld	a3,0(a4)
    800066de:	96be                	add	a3,a3,a5
    800066e0:	0006a423          	sw	zero,8(a3)
  disk.desc[i].flags = 0;
    800066e4:	6314                	ld	a3,0(a4)
    800066e6:	96be                	add	a3,a3,a5
    800066e8:	00069623          	sh	zero,12(a3)
  disk.desc[i].next = 0;
    800066ec:	6318                	ld	a4,0(a4)
    800066ee:	97ba                	add	a5,a5,a4
    800066f0:	00079723          	sh	zero,14(a5)
  disk.free[i] = 1;
    800066f4:	00018717          	auipc	a4,0x18
    800066f8:	90c70713          	addi	a4,a4,-1780 # 8001e000 <disk>
    800066fc:	972a                	add	a4,a4,a0
    800066fe:	6789                	lui	a5,0x2
    80006700:	97ba                	add	a5,a5,a4
    80006702:	4705                	li	a4,1
    80006704:	00e78c23          	sb	a4,24(a5) # 2018 <_entry-0x7fffdfe8>
  wakeup(&disk.free[0]);
    80006708:	0001a517          	auipc	a0,0x1a
    8000670c:	91050513          	addi	a0,a0,-1776 # 80020018 <disk+0x2018>
    80006710:	ffffc097          	auipc	ra,0xffffc
    80006714:	c32080e7          	jalr	-974(ra) # 80002342 <wakeup>
}
    80006718:	60a2                	ld	ra,8(sp)
    8000671a:	6402                	ld	s0,0(sp)
    8000671c:	0141                	addi	sp,sp,16
    8000671e:	8082                	ret
    panic("free_desc 1");
    80006720:	00002517          	auipc	a0,0x2
    80006724:	ff850513          	addi	a0,a0,-8 # 80008718 <syscalls+0x2f8>
    80006728:	ffffa097          	auipc	ra,0xffffa
    8000672c:	e04080e7          	jalr	-508(ra) # 8000052c <panic>
    panic("free_desc 2");
    80006730:	00002517          	auipc	a0,0x2
    80006734:	ff850513          	addi	a0,a0,-8 # 80008728 <syscalls+0x308>
    80006738:	ffffa097          	auipc	ra,0xffffa
    8000673c:	df4080e7          	jalr	-524(ra) # 8000052c <panic>

0000000080006740 <virtio_disk_init>:
{
    80006740:	1101                	addi	sp,sp,-32
    80006742:	ec06                	sd	ra,24(sp)
    80006744:	e822                	sd	s0,16(sp)
    80006746:	e426                	sd	s1,8(sp)
    80006748:	1000                	addi	s0,sp,32
  initlock(&disk.vdisk_lock, "virtio_disk");
    8000674a:	00002597          	auipc	a1,0x2
    8000674e:	fee58593          	addi	a1,a1,-18 # 80008738 <syscalls+0x318>
    80006752:	0001a517          	auipc	a0,0x1a
    80006756:	9d650513          	addi	a0,a0,-1578 # 80020128 <disk+0x2128>
    8000675a:	ffffa097          	auipc	ra,0xffffa
    8000675e:	3d8080e7          	jalr	984(ra) # 80000b32 <initlock>
  if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80006762:	100017b7          	lui	a5,0x10001
    80006766:	4398                	lw	a4,0(a5)
    80006768:	2701                	sext.w	a4,a4
    8000676a:	747277b7          	lui	a5,0x74727
    8000676e:	97678793          	addi	a5,a5,-1674 # 74726976 <_entry-0xb8d968a>
    80006772:	0ef71063          	bne	a4,a5,80006852 <virtio_disk_init+0x112>
     *R(VIRTIO_MMIO_VERSION) != 1 ||
    80006776:	100017b7          	lui	a5,0x10001
    8000677a:	43dc                	lw	a5,4(a5)
    8000677c:	2781                	sext.w	a5,a5
  if(*R(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    8000677e:	4705                	li	a4,1
    80006780:	0ce79963          	bne	a5,a4,80006852 <virtio_disk_init+0x112>
     *R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80006784:	100017b7          	lui	a5,0x10001
    80006788:	479c                	lw	a5,8(a5)
    8000678a:	2781                	sext.w	a5,a5
     *R(VIRTIO_MMIO_VERSION) != 1 ||
    8000678c:	4709                	li	a4,2
    8000678e:	0ce79263          	bne	a5,a4,80006852 <virtio_disk_init+0x112>
     *R(VIRTIO_MMIO_VENDOR_ID) != 0x554d4551){
    80006792:	100017b7          	lui	a5,0x10001
    80006796:	47d8                	lw	a4,12(a5)
    80006798:	2701                	sext.w	a4,a4
     *R(VIRTIO_MMIO_DEVICE_ID) != 2 ||
    8000679a:	554d47b7          	lui	a5,0x554d4
    8000679e:	55178793          	addi	a5,a5,1361 # 554d4551 <_entry-0x2ab2baaf>
    800067a2:	0af71863          	bne	a4,a5,80006852 <virtio_disk_init+0x112>
  *R(VIRTIO_MMIO_STATUS) = status;
    800067a6:	100017b7          	lui	a5,0x10001
    800067aa:	4705                	li	a4,1
    800067ac:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    800067ae:	470d                	li	a4,3
    800067b0:	dbb8                	sw	a4,112(a5)
  uint64 features = *R(VIRTIO_MMIO_DEVICE_FEATURES);
    800067b2:	4b98                	lw	a4,16(a5)
  *R(VIRTIO_MMIO_DRIVER_FEATURES) = features;
    800067b4:	c7ffe6b7          	lui	a3,0xc7ffe
    800067b8:	75f68693          	addi	a3,a3,1887 # ffffffffc7ffe75f <end+0xffffffff47fdd75f>
    800067bc:	8f75                	and	a4,a4,a3
    800067be:	d398                	sw	a4,32(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    800067c0:	472d                	li	a4,11
    800067c2:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_STATUS) = status;
    800067c4:	473d                	li	a4,15
    800067c6:	dbb8                	sw	a4,112(a5)
  *R(VIRTIO_MMIO_GUEST_PAGE_SIZE) = PGSIZE;
    800067c8:	6705                	lui	a4,0x1
    800067ca:	d798                	sw	a4,40(a5)
  *R(VIRTIO_MMIO_QUEUE_SEL) = 0;
    800067cc:	0207a823          	sw	zero,48(a5) # 10001030 <_entry-0x6fffefd0>
  uint32 max = *R(VIRTIO_MMIO_QUEUE_NUM_MAX);
    800067d0:	5bdc                	lw	a5,52(a5)
    800067d2:	2781                	sext.w	a5,a5
  if(max == 0)
    800067d4:	c7d9                	beqz	a5,80006862 <virtio_disk_init+0x122>
  if(max < NUM)
    800067d6:	471d                	li	a4,7
    800067d8:	08f77d63          	bgeu	a4,a5,80006872 <virtio_disk_init+0x132>
  *R(VIRTIO_MMIO_QUEUE_NUM) = NUM;
    800067dc:	100014b7          	lui	s1,0x10001
    800067e0:	47a1                	li	a5,8
    800067e2:	dc9c                	sw	a5,56(s1)
  memset(disk.pages, 0, sizeof(disk.pages));
    800067e4:	6609                	lui	a2,0x2
    800067e6:	4581                	li	a1,0
    800067e8:	00018517          	auipc	a0,0x18
    800067ec:	81850513          	addi	a0,a0,-2024 # 8001e000 <disk>
    800067f0:	ffffa097          	auipc	ra,0xffffa
    800067f4:	4ce080e7          	jalr	1230(ra) # 80000cbe <memset>
  *R(VIRTIO_MMIO_QUEUE_PFN) = ((uint64)disk.pages) >> PGSHIFT;
    800067f8:	00018717          	auipc	a4,0x18
    800067fc:	80870713          	addi	a4,a4,-2040 # 8001e000 <disk>
    80006800:	00c75793          	srli	a5,a4,0xc
    80006804:	2781                	sext.w	a5,a5
    80006806:	c0bc                	sw	a5,64(s1)
  disk.desc = (struct virtq_desc *) disk.pages;
    80006808:	00019797          	auipc	a5,0x19
    8000680c:	7f878793          	addi	a5,a5,2040 # 80020000 <disk+0x2000>
    80006810:	e398                	sd	a4,0(a5)
  disk.avail = (struct virtq_avail *)(disk.pages + NUM*sizeof(struct virtq_desc));
    80006812:	00018717          	auipc	a4,0x18
    80006816:	86e70713          	addi	a4,a4,-1938 # 8001e080 <disk+0x80>
    8000681a:	e798                	sd	a4,8(a5)
  disk.used = (struct virtq_used *) (disk.pages + PGSIZE);
    8000681c:	00018717          	auipc	a4,0x18
    80006820:	7e470713          	addi	a4,a4,2020 # 8001f000 <disk+0x1000>
    80006824:	eb98                	sd	a4,16(a5)
    disk.free[i] = 1;
    80006826:	4705                	li	a4,1
    80006828:	00e78c23          	sb	a4,24(a5)
    8000682c:	00e78ca3          	sb	a4,25(a5)
    80006830:	00e78d23          	sb	a4,26(a5)
    80006834:	00e78da3          	sb	a4,27(a5)
    80006838:	00e78e23          	sb	a4,28(a5)
    8000683c:	00e78ea3          	sb	a4,29(a5)
    80006840:	00e78f23          	sb	a4,30(a5)
    80006844:	00e78fa3          	sb	a4,31(a5)
}
    80006848:	60e2                	ld	ra,24(sp)
    8000684a:	6442                	ld	s0,16(sp)
    8000684c:	64a2                	ld	s1,8(sp)
    8000684e:	6105                	addi	sp,sp,32
    80006850:	8082                	ret
    panic("could not find virtio disk");
    80006852:	00002517          	auipc	a0,0x2
    80006856:	ef650513          	addi	a0,a0,-266 # 80008748 <syscalls+0x328>
    8000685a:	ffffa097          	auipc	ra,0xffffa
    8000685e:	cd2080e7          	jalr	-814(ra) # 8000052c <panic>
    panic("virtio disk has no queue 0");
    80006862:	00002517          	auipc	a0,0x2
    80006866:	f0650513          	addi	a0,a0,-250 # 80008768 <syscalls+0x348>
    8000686a:	ffffa097          	auipc	ra,0xffffa
    8000686e:	cc2080e7          	jalr	-830(ra) # 8000052c <panic>
    panic("virtio disk max queue too short");
    80006872:	00002517          	auipc	a0,0x2
    80006876:	f1650513          	addi	a0,a0,-234 # 80008788 <syscalls+0x368>
    8000687a:	ffffa097          	auipc	ra,0xffffa
    8000687e:	cb2080e7          	jalr	-846(ra) # 8000052c <panic>

0000000080006882 <virtio_disk_rw>:
  return 0;
}

void
virtio_disk_rw(struct buf *b, int write)
{
    80006882:	7119                	addi	sp,sp,-128
    80006884:	fc86                	sd	ra,120(sp)
    80006886:	f8a2                	sd	s0,112(sp)
    80006888:	f4a6                	sd	s1,104(sp)
    8000688a:	f0ca                	sd	s2,96(sp)
    8000688c:	ecce                	sd	s3,88(sp)
    8000688e:	e8d2                	sd	s4,80(sp)
    80006890:	e4d6                	sd	s5,72(sp)
    80006892:	e0da                	sd	s6,64(sp)
    80006894:	fc5e                	sd	s7,56(sp)
    80006896:	f862                	sd	s8,48(sp)
    80006898:	f466                	sd	s9,40(sp)
    8000689a:	f06a                	sd	s10,32(sp)
    8000689c:	ec6e                	sd	s11,24(sp)
    8000689e:	0100                	addi	s0,sp,128
    800068a0:	8aaa                	mv	s5,a0
    800068a2:	8d2e                	mv	s10,a1
  uint64 sector = b->blockno * (BSIZE / 512);
    800068a4:	00c52c83          	lw	s9,12(a0)
    800068a8:	001c9c9b          	slliw	s9,s9,0x1
    800068ac:	1c82                	slli	s9,s9,0x20
    800068ae:	020cdc93          	srli	s9,s9,0x20

  acquire(&disk.vdisk_lock);
    800068b2:	0001a517          	auipc	a0,0x1a
    800068b6:	87650513          	addi	a0,a0,-1930 # 80020128 <disk+0x2128>
    800068ba:	ffffa097          	auipc	ra,0xffffa
    800068be:	308080e7          	jalr	776(ra) # 80000bc2 <acquire>
  for(int i = 0; i < 3; i++){
    800068c2:	4981                	li	s3,0
  for(int i = 0; i < NUM; i++){
    800068c4:	44a1                	li	s1,8
      disk.free[i] = 0;
    800068c6:	00017c17          	auipc	s8,0x17
    800068ca:	73ac0c13          	addi	s8,s8,1850 # 8001e000 <disk>
    800068ce:	6b89                	lui	s7,0x2
  for(int i = 0; i < 3; i++){
    800068d0:	4b0d                	li	s6,3
    800068d2:	a0ad                	j	8000693c <virtio_disk_rw+0xba>
      disk.free[i] = 0;
    800068d4:	00fc0733          	add	a4,s8,a5
    800068d8:	975e                	add	a4,a4,s7
    800068da:	00070c23          	sb	zero,24(a4)
    idx[i] = alloc_desc();
    800068de:	c19c                	sw	a5,0(a1)
    if(idx[i] < 0){
    800068e0:	0207c563          	bltz	a5,8000690a <virtio_disk_rw+0x88>
  for(int i = 0; i < 3; i++){
    800068e4:	2905                	addiw	s2,s2,1
    800068e6:	0611                	addi	a2,a2,4 # 2004 <_entry-0x7fffdffc>
    800068e8:	19690c63          	beq	s2,s6,80006a80 <virtio_disk_rw+0x1fe>
    idx[i] = alloc_desc();
    800068ec:	85b2                	mv	a1,a2
  for(int i = 0; i < NUM; i++){
    800068ee:	00019717          	auipc	a4,0x19
    800068f2:	72a70713          	addi	a4,a4,1834 # 80020018 <disk+0x2018>
    800068f6:	87ce                	mv	a5,s3
    if(disk.free[i]){
    800068f8:	00074683          	lbu	a3,0(a4)
    800068fc:	fee1                	bnez	a3,800068d4 <virtio_disk_rw+0x52>
  for(int i = 0; i < NUM; i++){
    800068fe:	2785                	addiw	a5,a5,1
    80006900:	0705                	addi	a4,a4,1
    80006902:	fe979be3          	bne	a5,s1,800068f8 <virtio_disk_rw+0x76>
    idx[i] = alloc_desc();
    80006906:	57fd                	li	a5,-1
    80006908:	c19c                	sw	a5,0(a1)
      for(int j = 0; j < i; j++)
    8000690a:	01205d63          	blez	s2,80006924 <virtio_disk_rw+0xa2>
    8000690e:	8dce                	mv	s11,s3
        free_desc(idx[j]);
    80006910:	000a2503          	lw	a0,0(s4)
    80006914:	00000097          	auipc	ra,0x0
    80006918:	d92080e7          	jalr	-622(ra) # 800066a6 <free_desc>
      for(int j = 0; j < i; j++)
    8000691c:	2d85                	addiw	s11,s11,1
    8000691e:	0a11                	addi	s4,s4,4
    80006920:	ff2d98e3          	bne	s11,s2,80006910 <virtio_disk_rw+0x8e>
  int idx[3];
  while(1){
    if(alloc3_desc(idx) == 0) {
      break;
    }
    sleep(&disk.free[0], &disk.vdisk_lock);
    80006924:	0001a597          	auipc	a1,0x1a
    80006928:	80458593          	addi	a1,a1,-2044 # 80020128 <disk+0x2128>
    8000692c:	00019517          	auipc	a0,0x19
    80006930:	6ec50513          	addi	a0,a0,1772 # 80020018 <disk+0x2018>
    80006934:	ffffc097          	auipc	ra,0xffffc
    80006938:	88e080e7          	jalr	-1906(ra) # 800021c2 <sleep>
  for(int i = 0; i < 3; i++){
    8000693c:	f8040a13          	addi	s4,s0,-128
{
    80006940:	8652                	mv	a2,s4
  for(int i = 0; i < 3; i++){
    80006942:	894e                	mv	s2,s3
    80006944:	b765                	j	800068ec <virtio_disk_rw+0x6a>
  disk.desc[idx[0]].next = idx[1];

  disk.desc[idx[1]].addr = (uint64) b->data;
  disk.desc[idx[1]].len = BSIZE;
  if(write)
    disk.desc[idx[1]].flags = 0; // device reads b->data
    80006946:	00019697          	auipc	a3,0x19
    8000694a:	6ba6b683          	ld	a3,1722(a3) # 80020000 <disk+0x2000>
    8000694e:	96ba                	add	a3,a3,a4
    80006950:	00069623          	sh	zero,12(a3)
  else
    disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
  disk.desc[idx[1]].flags |= VRING_DESC_F_NEXT;
    80006954:	00017817          	auipc	a6,0x17
    80006958:	6ac80813          	addi	a6,a6,1708 # 8001e000 <disk>
    8000695c:	00019697          	auipc	a3,0x19
    80006960:	6a468693          	addi	a3,a3,1700 # 80020000 <disk+0x2000>
    80006964:	6290                	ld	a2,0(a3)
    80006966:	963a                	add	a2,a2,a4
    80006968:	00c65583          	lhu	a1,12(a2)
    8000696c:	0015e593          	ori	a1,a1,1
    80006970:	00b61623          	sh	a1,12(a2)
  disk.desc[idx[1]].next = idx[2];
    80006974:	f8842603          	lw	a2,-120(s0)
    80006978:	628c                	ld	a1,0(a3)
    8000697a:	972e                	add	a4,a4,a1
    8000697c:	00c71723          	sh	a2,14(a4)

  disk.info[idx[0]].status = 0xff; // device writes 0 on success
    80006980:	20050593          	addi	a1,a0,512
    80006984:	0592                	slli	a1,a1,0x4
    80006986:	95c2                	add	a1,a1,a6
    80006988:	577d                	li	a4,-1
    8000698a:	02e58823          	sb	a4,48(a1)
  disk.desc[idx[2]].addr = (uint64) &disk.info[idx[0]].status;
    8000698e:	00461713          	slli	a4,a2,0x4
    80006992:	6290                	ld	a2,0(a3)
    80006994:	963a                	add	a2,a2,a4
    80006996:	03078793          	addi	a5,a5,48
    8000699a:	97c2                	add	a5,a5,a6
    8000699c:	e21c                	sd	a5,0(a2)
  disk.desc[idx[2]].len = 1;
    8000699e:	629c                	ld	a5,0(a3)
    800069a0:	97ba                	add	a5,a5,a4
    800069a2:	4605                	li	a2,1
    800069a4:	c790                	sw	a2,8(a5)
  disk.desc[idx[2]].flags = VRING_DESC_F_WRITE; // device writes the status
    800069a6:	629c                	ld	a5,0(a3)
    800069a8:	97ba                	add	a5,a5,a4
    800069aa:	4809                	li	a6,2
    800069ac:	01079623          	sh	a6,12(a5)
  disk.desc[idx[2]].next = 0;
    800069b0:	629c                	ld	a5,0(a3)
    800069b2:	97ba                	add	a5,a5,a4
    800069b4:	00079723          	sh	zero,14(a5)

  // record struct buf for virtio_disk_intr().
  b->disk = 1;
    800069b8:	00caa223          	sw	a2,4(s5)
  disk.info[idx[0]].b = b;
    800069bc:	0355b423          	sd	s5,40(a1)

  // tell the device the first index in our chain of descriptors.
  disk.avail->ring[disk.avail->idx % NUM] = idx[0];
    800069c0:	6698                	ld	a4,8(a3)
    800069c2:	00275783          	lhu	a5,2(a4)
    800069c6:	8b9d                	andi	a5,a5,7
    800069c8:	0786                	slli	a5,a5,0x1
    800069ca:	973e                	add	a4,a4,a5
    800069cc:	00a71223          	sh	a0,4(a4)

  __sync_synchronize();
    800069d0:	0ff0000f          	fence

  // tell the device another avail ring entry is available.
  disk.avail->idx += 1; // not % NUM ...
    800069d4:	6698                	ld	a4,8(a3)
    800069d6:	00275783          	lhu	a5,2(a4)
    800069da:	2785                	addiw	a5,a5,1
    800069dc:	00f71123          	sh	a5,2(a4)

  __sync_synchronize();
    800069e0:	0ff0000f          	fence

  *R(VIRTIO_MMIO_QUEUE_NOTIFY) = 0; // value is queue number
    800069e4:	100017b7          	lui	a5,0x10001
    800069e8:	0407a823          	sw	zero,80(a5) # 10001050 <_entry-0x6fffefb0>

  // Wait for virtio_disk_intr() to say request has finished.
  while(b->disk == 1) {
    800069ec:	004aa783          	lw	a5,4(s5)
    800069f0:	02c79163          	bne	a5,a2,80006a12 <virtio_disk_rw+0x190>
    sleep(b, &disk.vdisk_lock);
    800069f4:	00019917          	auipc	s2,0x19
    800069f8:	73490913          	addi	s2,s2,1844 # 80020128 <disk+0x2128>
  while(b->disk == 1) {
    800069fc:	4485                	li	s1,1
    sleep(b, &disk.vdisk_lock);
    800069fe:	85ca                	mv	a1,s2
    80006a00:	8556                	mv	a0,s5
    80006a02:	ffffb097          	auipc	ra,0xffffb
    80006a06:	7c0080e7          	jalr	1984(ra) # 800021c2 <sleep>
  while(b->disk == 1) {
    80006a0a:	004aa783          	lw	a5,4(s5)
    80006a0e:	fe9788e3          	beq	a5,s1,800069fe <virtio_disk_rw+0x17c>
  }

  disk.info[idx[0]].b = 0;
    80006a12:	f8042903          	lw	s2,-128(s0)
    80006a16:	20090713          	addi	a4,s2,512
    80006a1a:	0712                	slli	a4,a4,0x4
    80006a1c:	00017797          	auipc	a5,0x17
    80006a20:	5e478793          	addi	a5,a5,1508 # 8001e000 <disk>
    80006a24:	97ba                	add	a5,a5,a4
    80006a26:	0207b423          	sd	zero,40(a5)
    int flag = disk.desc[i].flags;
    80006a2a:	00019997          	auipc	s3,0x19
    80006a2e:	5d698993          	addi	s3,s3,1494 # 80020000 <disk+0x2000>
    80006a32:	00491713          	slli	a4,s2,0x4
    80006a36:	0009b783          	ld	a5,0(s3)
    80006a3a:	97ba                	add	a5,a5,a4
    80006a3c:	00c7d483          	lhu	s1,12(a5)
    int nxt = disk.desc[i].next;
    80006a40:	854a                	mv	a0,s2
    80006a42:	00e7d903          	lhu	s2,14(a5)
    free_desc(i);
    80006a46:	00000097          	auipc	ra,0x0
    80006a4a:	c60080e7          	jalr	-928(ra) # 800066a6 <free_desc>
    if(flag & VRING_DESC_F_NEXT)
    80006a4e:	8885                	andi	s1,s1,1
    80006a50:	f0ed                	bnez	s1,80006a32 <virtio_disk_rw+0x1b0>
  free_chain(idx[0]);

  release(&disk.vdisk_lock);
    80006a52:	00019517          	auipc	a0,0x19
    80006a56:	6d650513          	addi	a0,a0,1750 # 80020128 <disk+0x2128>
    80006a5a:	ffffa097          	auipc	ra,0xffffa
    80006a5e:	21c080e7          	jalr	540(ra) # 80000c76 <release>
}
    80006a62:	70e6                	ld	ra,120(sp)
    80006a64:	7446                	ld	s0,112(sp)
    80006a66:	74a6                	ld	s1,104(sp)
    80006a68:	7906                	ld	s2,96(sp)
    80006a6a:	69e6                	ld	s3,88(sp)
    80006a6c:	6a46                	ld	s4,80(sp)
    80006a6e:	6aa6                	ld	s5,72(sp)
    80006a70:	6b06                	ld	s6,64(sp)
    80006a72:	7be2                	ld	s7,56(sp)
    80006a74:	7c42                	ld	s8,48(sp)
    80006a76:	7ca2                	ld	s9,40(sp)
    80006a78:	7d02                	ld	s10,32(sp)
    80006a7a:	6de2                	ld	s11,24(sp)
    80006a7c:	6109                	addi	sp,sp,128
    80006a7e:	8082                	ret
  struct virtio_blk_req *buf0 = &disk.ops[idx[0]];
    80006a80:	f8042503          	lw	a0,-128(s0)
    80006a84:	20050793          	addi	a5,a0,512
    80006a88:	0792                	slli	a5,a5,0x4
  if(write)
    80006a8a:	00017817          	auipc	a6,0x17
    80006a8e:	57680813          	addi	a6,a6,1398 # 8001e000 <disk>
    80006a92:	00f80733          	add	a4,a6,a5
    80006a96:	01a036b3          	snez	a3,s10
    80006a9a:	0ad72423          	sw	a3,168(a4)
  buf0->reserved = 0;
    80006a9e:	0a072623          	sw	zero,172(a4)
  buf0->sector = sector;
    80006aa2:	0b973823          	sd	s9,176(a4)
  disk.desc[idx[0]].addr = (uint64) buf0;
    80006aa6:	7679                	lui	a2,0xffffe
    80006aa8:	963e                	add	a2,a2,a5
    80006aaa:	00019697          	auipc	a3,0x19
    80006aae:	55668693          	addi	a3,a3,1366 # 80020000 <disk+0x2000>
    80006ab2:	6298                	ld	a4,0(a3)
    80006ab4:	9732                	add	a4,a4,a2
  struct virtio_blk_req *buf0 = &disk.ops[idx[0]];
    80006ab6:	0a878593          	addi	a1,a5,168
    80006aba:	95c2                	add	a1,a1,a6
  disk.desc[idx[0]].addr = (uint64) buf0;
    80006abc:	e30c                	sd	a1,0(a4)
  disk.desc[idx[0]].len = sizeof(struct virtio_blk_req);
    80006abe:	6298                	ld	a4,0(a3)
    80006ac0:	9732                	add	a4,a4,a2
    80006ac2:	45c1                	li	a1,16
    80006ac4:	c70c                	sw	a1,8(a4)
  disk.desc[idx[0]].flags = VRING_DESC_F_NEXT;
    80006ac6:	6298                	ld	a4,0(a3)
    80006ac8:	9732                	add	a4,a4,a2
    80006aca:	4585                	li	a1,1
    80006acc:	00b71623          	sh	a1,12(a4)
  disk.desc[idx[0]].next = idx[1];
    80006ad0:	f8442703          	lw	a4,-124(s0)
    80006ad4:	628c                	ld	a1,0(a3)
    80006ad6:	962e                	add	a2,a2,a1
    80006ad8:	00e61723          	sh	a4,14(a2) # ffffffffffffe00e <end+0xffffffff7ffdd00e>
  disk.desc[idx[1]].addr = (uint64) b->data;
    80006adc:	0712                	slli	a4,a4,0x4
    80006ade:	6290                	ld	a2,0(a3)
    80006ae0:	963a                	add	a2,a2,a4
    80006ae2:	058a8593          	addi	a1,s5,88
    80006ae6:	e20c                	sd	a1,0(a2)
  disk.desc[idx[1]].len = BSIZE;
    80006ae8:	6294                	ld	a3,0(a3)
    80006aea:	96ba                	add	a3,a3,a4
    80006aec:	40000613          	li	a2,1024
    80006af0:	c690                	sw	a2,8(a3)
  if(write)
    80006af2:	e40d1ae3          	bnez	s10,80006946 <virtio_disk_rw+0xc4>
    disk.desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
    80006af6:	00019697          	auipc	a3,0x19
    80006afa:	50a6b683          	ld	a3,1290(a3) # 80020000 <disk+0x2000>
    80006afe:	96ba                	add	a3,a3,a4
    80006b00:	4609                	li	a2,2
    80006b02:	00c69623          	sh	a2,12(a3)
    80006b06:	b5b9                	j	80006954 <virtio_disk_rw+0xd2>

0000000080006b08 <virtio_disk_intr>:

void
virtio_disk_intr()
{
    80006b08:	1101                	addi	sp,sp,-32
    80006b0a:	ec06                	sd	ra,24(sp)
    80006b0c:	e822                	sd	s0,16(sp)
    80006b0e:	e426                	sd	s1,8(sp)
    80006b10:	e04a                	sd	s2,0(sp)
    80006b12:	1000                	addi	s0,sp,32
  acquire(&disk.vdisk_lock);
    80006b14:	00019517          	auipc	a0,0x19
    80006b18:	61450513          	addi	a0,a0,1556 # 80020128 <disk+0x2128>
    80006b1c:	ffffa097          	auipc	ra,0xffffa
    80006b20:	0a6080e7          	jalr	166(ra) # 80000bc2 <acquire>
  // we've seen this interrupt, which the following line does.
  // this may race with the device writing new entries to
  // the "used" ring, in which case we may process the new
  // completion entries in this interrupt, and have nothing to do
  // in the next interrupt, which is harmless.
  *R(VIRTIO_MMIO_INTERRUPT_ACK) = *R(VIRTIO_MMIO_INTERRUPT_STATUS) & 0x3;
    80006b24:	10001737          	lui	a4,0x10001
    80006b28:	533c                	lw	a5,96(a4)
    80006b2a:	8b8d                	andi	a5,a5,3
    80006b2c:	d37c                	sw	a5,100(a4)

  __sync_synchronize();
    80006b2e:	0ff0000f          	fence

  // the device increments disk.used->idx when it
  // adds an entry to the used ring.

  while(disk.used_idx != disk.used->idx){
    80006b32:	00019797          	auipc	a5,0x19
    80006b36:	4ce78793          	addi	a5,a5,1230 # 80020000 <disk+0x2000>
    80006b3a:	6b94                	ld	a3,16(a5)
    80006b3c:	0207d703          	lhu	a4,32(a5)
    80006b40:	0026d783          	lhu	a5,2(a3)
    80006b44:	06f70163          	beq	a4,a5,80006ba6 <virtio_disk_intr+0x9e>
    __sync_synchronize();
    int id = disk.used->ring[disk.used_idx % NUM].id;
    80006b48:	00017917          	auipc	s2,0x17
    80006b4c:	4b890913          	addi	s2,s2,1208 # 8001e000 <disk>
    80006b50:	00019497          	auipc	s1,0x19
    80006b54:	4b048493          	addi	s1,s1,1200 # 80020000 <disk+0x2000>
    __sync_synchronize();
    80006b58:	0ff0000f          	fence
    int id = disk.used->ring[disk.used_idx % NUM].id;
    80006b5c:	6898                	ld	a4,16(s1)
    80006b5e:	0204d783          	lhu	a5,32(s1)
    80006b62:	8b9d                	andi	a5,a5,7
    80006b64:	078e                	slli	a5,a5,0x3
    80006b66:	97ba                	add	a5,a5,a4
    80006b68:	43dc                	lw	a5,4(a5)

    if(disk.info[id].status != 0)
    80006b6a:	20078713          	addi	a4,a5,512
    80006b6e:	0712                	slli	a4,a4,0x4
    80006b70:	974a                	add	a4,a4,s2
    80006b72:	03074703          	lbu	a4,48(a4) # 10001030 <_entry-0x6fffefd0>
    80006b76:	e731                	bnez	a4,80006bc2 <virtio_disk_intr+0xba>
      panic("virtio_disk_intr status");

    struct buf *b = disk.info[id].b;
    80006b78:	20078793          	addi	a5,a5,512
    80006b7c:	0792                	slli	a5,a5,0x4
    80006b7e:	97ca                	add	a5,a5,s2
    80006b80:	7788                	ld	a0,40(a5)
    b->disk = 0;   // disk is done with buf
    80006b82:	00052223          	sw	zero,4(a0)
    wakeup(b);
    80006b86:	ffffb097          	auipc	ra,0xffffb
    80006b8a:	7bc080e7          	jalr	1980(ra) # 80002342 <wakeup>

    disk.used_idx += 1;
    80006b8e:	0204d783          	lhu	a5,32(s1)
    80006b92:	2785                	addiw	a5,a5,1
    80006b94:	17c2                	slli	a5,a5,0x30
    80006b96:	93c1                	srli	a5,a5,0x30
    80006b98:	02f49023          	sh	a5,32(s1)
  while(disk.used_idx != disk.used->idx){
    80006b9c:	6898                	ld	a4,16(s1)
    80006b9e:	00275703          	lhu	a4,2(a4)
    80006ba2:	faf71be3          	bne	a4,a5,80006b58 <virtio_disk_intr+0x50>
  }

  release(&disk.vdisk_lock);
    80006ba6:	00019517          	auipc	a0,0x19
    80006baa:	58250513          	addi	a0,a0,1410 # 80020128 <disk+0x2128>
    80006bae:	ffffa097          	auipc	ra,0xffffa
    80006bb2:	0c8080e7          	jalr	200(ra) # 80000c76 <release>
}
    80006bb6:	60e2                	ld	ra,24(sp)
    80006bb8:	6442                	ld	s0,16(sp)
    80006bba:	64a2                	ld	s1,8(sp)
    80006bbc:	6902                	ld	s2,0(sp)
    80006bbe:	6105                	addi	sp,sp,32
    80006bc0:	8082                	ret
      panic("virtio_disk_intr status");
    80006bc2:	00002517          	auipc	a0,0x2
    80006bc6:	be650513          	addi	a0,a0,-1050 # 800087a8 <syscalls+0x388>
    80006bca:	ffffa097          	auipc	ra,0xffffa
    80006bce:	962080e7          	jalr	-1694(ra) # 8000052c <panic>
	...

0000000080007000 <_trampoline>:
    80007000:	14051573          	csrrw	a0,sscratch,a0
    80007004:	02153423          	sd	ra,40(a0)
    80007008:	02253823          	sd	sp,48(a0)
    8000700c:	02353c23          	sd	gp,56(a0)
    80007010:	04453023          	sd	tp,64(a0)
    80007014:	04553423          	sd	t0,72(a0)
    80007018:	04653823          	sd	t1,80(a0)
    8000701c:	04753c23          	sd	t2,88(a0)
    80007020:	f120                	sd	s0,96(a0)
    80007022:	f524                	sd	s1,104(a0)
    80007024:	fd2c                	sd	a1,120(a0)
    80007026:	e150                	sd	a2,128(a0)
    80007028:	e554                	sd	a3,136(a0)
    8000702a:	e958                	sd	a4,144(a0)
    8000702c:	ed5c                	sd	a5,152(a0)
    8000702e:	0b053023          	sd	a6,160(a0)
    80007032:	0b153423          	sd	a7,168(a0)
    80007036:	0b253823          	sd	s2,176(a0)
    8000703a:	0b353c23          	sd	s3,184(a0)
    8000703e:	0d453023          	sd	s4,192(a0)
    80007042:	0d553423          	sd	s5,200(a0)
    80007046:	0d653823          	sd	s6,208(a0)
    8000704a:	0d753c23          	sd	s7,216(a0)
    8000704e:	0f853023          	sd	s8,224(a0)
    80007052:	0f953423          	sd	s9,232(a0)
    80007056:	0fa53823          	sd	s10,240(a0)
    8000705a:	0fb53c23          	sd	s11,248(a0)
    8000705e:	11c53023          	sd	t3,256(a0)
    80007062:	11d53423          	sd	t4,264(a0)
    80007066:	11e53823          	sd	t5,272(a0)
    8000706a:	11f53c23          	sd	t6,280(a0)
    8000706e:	140022f3          	csrr	t0,sscratch
    80007072:	06553823          	sd	t0,112(a0)
    80007076:	00853103          	ld	sp,8(a0)
    8000707a:	02053203          	ld	tp,32(a0)
    8000707e:	01053283          	ld	t0,16(a0)
    80007082:	00053303          	ld	t1,0(a0)
    80007086:	18031073          	csrw	satp,t1
    8000708a:	12000073          	sfence.vma
    8000708e:	8282                	jr	t0

0000000080007090 <userret>:
    80007090:	18059073          	csrw	satp,a1
    80007094:	12000073          	sfence.vma
    80007098:	07053283          	ld	t0,112(a0)
    8000709c:	14029073          	csrw	sscratch,t0
    800070a0:	02853083          	ld	ra,40(a0)
    800070a4:	03053103          	ld	sp,48(a0)
    800070a8:	03853183          	ld	gp,56(a0)
    800070ac:	04053203          	ld	tp,64(a0)
    800070b0:	04853283          	ld	t0,72(a0)
    800070b4:	05053303          	ld	t1,80(a0)
    800070b8:	05853383          	ld	t2,88(a0)
    800070bc:	7120                	ld	s0,96(a0)
    800070be:	7524                	ld	s1,104(a0)
    800070c0:	7d2c                	ld	a1,120(a0)
    800070c2:	6150                	ld	a2,128(a0)
    800070c4:	6554                	ld	a3,136(a0)
    800070c6:	6958                	ld	a4,144(a0)
    800070c8:	6d5c                	ld	a5,152(a0)
    800070ca:	0a053803          	ld	a6,160(a0)
    800070ce:	0a853883          	ld	a7,168(a0)
    800070d2:	0b053903          	ld	s2,176(a0)
    800070d6:	0b853983          	ld	s3,184(a0)
    800070da:	0c053a03          	ld	s4,192(a0)
    800070de:	0c853a83          	ld	s5,200(a0)
    800070e2:	0d053b03          	ld	s6,208(a0)
    800070e6:	0d853b83          	ld	s7,216(a0)
    800070ea:	0e053c03          	ld	s8,224(a0)
    800070ee:	0e853c83          	ld	s9,232(a0)
    800070f2:	0f053d03          	ld	s10,240(a0)
    800070f6:	0f853d83          	ld	s11,248(a0)
    800070fa:	10053e03          	ld	t3,256(a0)
    800070fe:	10853e83          	ld	t4,264(a0)
    80007102:	11053f03          	ld	t5,272(a0)
    80007106:	11853f83          	ld	t6,280(a0)
    8000710a:	14051573          	csrrw	a0,sscratch,a0
    8000710e:	10200073          	sret
	...
